setting.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <view class="page">
  3. <!-- 菜单 -->
  4. <view class="menu-list-wrap box-shadow">
  5. <view class="menu-item" @click="openGzhPopup">
  6. <view class="menu-title-wrap">
  7. <view class="title">
  8. <u-icon class="u-m-r-10" name="weixin-fill" color="#07c160" size="40"></u-icon>
  9. 公众号推送提醒(房秒签)
  10. </view>
  11. </view>
  12. <u-icon name="arrow-right" :label-color="userInfo2.is_notice == 1 ? '#2979ff' : '#f00'" size="24" :label="userInfo2.is_notice === '1' ? '已开启' : '已关闭'" labelPos="left"></u-icon>
  13. </view>
  14. <!-- #ifdef MP-WEIXIN -->
  15. <view v-if="userInfo2.bind_wechat === '1'" class="menu-item">
  16. <view class="menu-title-wrap">
  17. <view class="title">
  18. <u-icon class="u-m-r-10" name="weixin-fill" color="#07c160" size="40"></u-icon>
  19. 绑定微信
  20. </view>
  21. </view>
  22. <u-icon name="arrow-right" size="24" :label="userInfo2.bind_wechat === '1' ? '已绑定' : '未绑定'" labelPos="left"></u-icon>
  23. </view>
  24. <button v-else open-type="getPhoneNumber" @getphonenumber="getphonenumber" class="menu-item scoped-btn-to-div">
  25. <view class="menu-title-wrap">
  26. <view class="title">
  27. <u-icon class="u-m-r-10" name="weixin-fill" color="#07c160" size="40"></u-icon>
  28. 绑定微信
  29. </view>
  30. </view>
  31. <u-icon name="arrow-right" size="24" :label="userInfo2.bind_wechat === '1' ? '已绑定' : '未绑定'" labelPos="left"></u-icon>
  32. </button>
  33. <!-- #endif -->
  34. <view class="menu-item" @click="pageTo('/pages/user/setting/profile')">
  35. <view class="menu-title-wrap">
  36. <view class="title">
  37. <u-icon class="u-m-r-10" name="/static/icon/notebook.png" size="36"></u-icon>
  38. 修改个人信息
  39. </view>
  40. </view>
  41. <u-icon name="arrow-right" size="24" labelPos="left" label="修改昵称/密码"></u-icon>
  42. </view>
  43. <view class="menu-item" @click="pageTo('/pages/user/setting/bank')">
  44. <view class="menu-title-wrap">
  45. <view class="title">
  46. <u-icon class="u-m-r-10" name="/static/icon/bank-card.png" size="36"></u-icon>
  47. 补全身份认证信息
  48. </view>
  49. </view>
  50. <u-icon name="arrow-right" size="24" :label="userInfo2.auth_state === '1' ? `已认证(渠道码:${userInfo2.dept_code || '未知'})` : '待认证'" labelPos="left"></u-icon>
  51. </view>
  52. <!-- #ifdef MP-WEIXIN -->
  53. <view class="menu-item" @click="checkUpdate()">
  54. <view class="menu-title-wrap">
  55. <view class="title">
  56. <u-icon class="u-m-r-10" name="/static/icon/balloon.png" size="36"></u-icon>
  57. 检查最新版本
  58. </view>
  59. </view>
  60. <u-icon name="arrow-right" size="24"></u-icon>
  61. </view>
  62. <!-- #endif -->
  63. <view v-if="userInfo2.roles == 1 || userInfo2.roles == 5 || userInfo2.roles == 7 || userInfo2.roles == 10 || userInfo2.roles == 11" class="menu-item" @click="pageTo('/pages/estate/libPre')">
  64. <view class="menu-title-wrap">
  65. <view class="title">
  66. <u-icon class="u-m-r-10" name="/static/icon/notebook.png" size="36"></u-icon>
  67. 各楼盘各平台佣金汇集
  68. </view>
  69. </view>
  70. <u-icon name="arrow-right" size="24" labelPos="left"></u-icon>
  71. </view>
  72. <view v-if="userInfo2.roles == 1 || userInfo2.roles == 5 || userInfo2.roles == 7 || userInfo2.roles == 10 || userInfo2.roles == 11" class="menu-item" @click="pageTo('/pages/shop/map')">
  73. <view class="menu-title-wrap">
  74. <view class="title">
  75. <u-icon class="u-m-r-10" name="/static/icon/notebook.png" size="36"></u-icon>
  76. 门店渠道地图
  77. </view>
  78. </view>
  79. <u-icon name="arrow-right" size="24" labelPos="left"></u-icon>
  80. </view>
  81. </view>
  82. <view class="menu-list-wrap box-shadow">
  83. <view class="menu-item" @click="pageTo('/pages/index/web?url=https://h5.fangpiaovip.com')">
  84. <view class="menu-title-wrap">
  85. <view class="title">
  86. <u-icon class="u-m-r-10 u-m-t-6" name="/static/icon/handshake.png" size="36"></u-icon>
  87. 使用指南(教你认证)
  88. </view>
  89. </view>
  90. <u-icon name="arrow-right" size="24"></u-icon>
  91. </view>
  92. <view class="menu-item" @click="pageTo('dev', '/pages/user/help/suggest')">
  93. <view class="menu-title-wrap">
  94. <view class="title">
  95. <u-icon class="u-m-r-10" name="/static/icon/mail-box.png" size="36"></u-icon>
  96. 意见建议
  97. </view>
  98. </view>
  99. <u-icon name="arrow-right" size="24"></u-icon>
  100. </view>
  101. <view class="menu-item" @click="pageTo('/pages/agreement/agreement?type=user_agreement')">
  102. <view class="menu-title-wrap">
  103. <view class="title">
  104. <u-icon class="u-m-r-10" name="/static/icon/agreement.png" size="36"></u-icon>
  105. 用户协议
  106. </view>
  107. </view>
  108. <u-icon name="arrow-right" size="24"></u-icon>
  109. </view>
  110. <view class="menu-item" @click="pageTo('/pages/agreement/agreement2?type=privacy_agreement')">
  111. <view class="menu-title-wrap">
  112. <view class="title">
  113. <u-icon class="u-m-r-10" name="/static/icon/agreement.png" size="36"></u-icon>
  114. 隐私协议
  115. </view>
  116. </view>
  117. <u-icon name="arrow-right" size="24"></u-icon>
  118. </view>
  119. <!-- <view class="menu-item" @click="logoffModalShow = true">
  120. <view class="menu-title-wrap">
  121. <view class="title">
  122. <u-icon class="u-m-r-10" name="/static/icon/lock.png" size="36"></u-icon>
  123. 注销账号
  124. </view>
  125. </view>
  126. <u-icon name="arrow-right" size="24"></u-icon>
  127. </view> -->
  128. </view>
  129. <u-button type="primary" @click="logout">注销登录</u-button>
  130. <!-- 授权微信资料弹窗 -->
  131. <!-- 平台佣金政策弹窗 -->
  132. <u-popup v-model="editWeixinUserInfoPopupShow" mode="center" width="80%" height="440rpx" border-radius="20">
  133. <view class="bwin-popup">
  134. <view class="popup-header">同步微信资料</view>
  135. <view class="popup-body">
  136. <view class="choose-avatar u-m-b-20">
  137. <u-avatar :src="form.avatarUrl" size="128" showLevel levelIcon="edit-pen" levelBgColor="#2979ff"></u-avatar>
  138. <button
  139. class="u-reset-button"
  140. style="width: 128rpx;height: 128rpx;position: absolute;left: 0;top: 0;"
  141. open-type="chooseAvatar"
  142. @chooseavatar="bindWeixinAvatar"
  143. ></button>
  144. </view>
  145. <u-input border placeholder="点击可使用微信昵称填充" v-model="form.nickname" style="width: 100%;" type="nickname"></u-input>
  146. </view>
  147. <view class="popup-footer" style="position: absolute;">
  148. <u-button size="medium" @click="editWeixinUserInfoPopupShow = false">取消</u-button>
  149. <u-button size="medium" type="primary" @click="updateUserInfoByWeixin()">保存</u-button>
  150. </view>
  151. </view>
  152. </u-popup>
  153. <!-- 服务号 弹窗 -->
  154. <u-popup v-model="gzhShow" mode="center" width="80%" height="440rpx" border-radius="20">
  155. <view class="bwin-popup">
  156. <view class="popup-header">关注房秒签公众号</view>
  157. <view class="popup-body">
  158. <image src="/static/gzh.jpg" class="scoped-scan-img" mode="widthFix" @click="scanHandle"></image>
  159. </view>
  160. <view class="popup-footer" style="position: absolute;">
  161. <u-button size="medium" @click="closeGzhPopup">{{userInfo2.is_notice == 1 ? '关闭推送' : '已关注公众号,点击开启推送'}}</u-button>
  162. </view>
  163. </view>
  164. </u-popup>
  165. <!-- 注销账号modal -->
  166. <u-modal
  167. v-model="logoffModalShow"
  168. title="重要提示"
  169. content="提交后,您的账号将被彻底删除,包括但不限于您的推荐记录、佣金结算记录等均将被同步删除。请确认是否仍要注销您的账号?"
  170. showCancelButton
  171. @cancel="logoffModalShow = false"
  172. @confirm="uni.toast('已提交注销申请')"
  173. ></u-modal>
  174. </view>
  175. </template>
  176. <script>
  177. var that;
  178. export default {
  179. data() {
  180. return {
  181. gzhShow: false,
  182. userInfo: {},
  183. userInfo2: {},
  184. logoffModalShow: false, // 注销提示
  185. editWeixinUserInfoPopupShow: false, // 补全微信资料
  186. form: {
  187. avatarUrl: null,
  188. nickname: ''
  189. }
  190. };
  191. },
  192. onLoad() {
  193. },
  194. onShow() {
  195. this.getUserInfo()
  196. },
  197. onReady() {},
  198. methods: {
  199. scanHandle () {
  200. uni.previewImage({
  201. current: 'https://img.fangpiaovip.com/20221031044744-8466.png',
  202. urls: ['https://img.fangpiaovip.com/20221031044744-8466.png'],
  203. })
  204. },
  205. openGzhPopup () {
  206. this.gzhShow = true
  207. },
  208. closeGzhPopup () {
  209. let str = 'apiusernoticeopen'
  210. let bcTips = '开启推送成功'
  211. if (this.userInfo2.is_notice == 1) {
  212. str = 'apiusernoticeclose'
  213. bcTips = '已关闭推送'
  214. }
  215. uni.api.base[str]().then(res => {
  216. uni.$msg(bcTips)
  217. this.getUserInfo()
  218. this.gzhShow = false
  219. })
  220. },
  221. getUserInfo () {
  222. uni.api.base.apiuserinfo().then(res => {
  223. uni.setStorageSync('MD_userInfo2', res)
  224. this.userInfo2 = res || {}
  225. })
  226. },
  227. pageTo(path) {
  228. if (path === 'dev') {
  229. uni.$msg('开发中~')
  230. return
  231. }
  232. uni.navigateTo({
  233. url: path
  234. })
  235. },
  236. // 绑定微信号
  237. getphonenumber(e) {
  238. const dtlObj = e.detail || {}
  239. let that = this
  240. uni.login({
  241. success: function (res) {
  242. if (res.code) {
  243. uni.api.base.apiuserbindwechat({
  244. code: res.code,
  245. phone_code: dtlObj.code,
  246. }).then(cData => {
  247. that.getUserInfo()
  248. }).catch(err => {
  249. console.log(err)
  250. })
  251. } else {
  252. console.log('登录失败!' + res.errMsg)
  253. }
  254. }
  255. })
  256. // if (vk.vuex.get('$user.userInfo.wx_openid')) {
  257. // let currentTime = Date.parse(new Date()) / 1000; // 秒级
  258. // if (currentTime - vk.vuex.get('$user.history.lastEditUserInfoTime') <= 86400) {
  259. // vk.alert('已绑定微信,用户资料在每7天内仅允许修改一次', '提示', '确定');
  260. // } else {
  261. // that.editWeixinUserInfoPopupShow = true;
  262. // }
  263. // return;
  264. // }
  265. // vk.userCenter.bindWeixin({
  266. // success: data => {
  267. // // 成功后的逻辑
  268. // vk.alert('绑定成功,请继续设置头像、昵称', '提示', '确定', function() {
  269. // that.editWeixinUserInfoPopupShow = true;
  270. // });
  271. // console.log(data);
  272. // }
  273. // });
  274. },
  275. // 获取用户微信头像
  276. bindWeixinAvatar(e) {
  277. let { avatarUrl } = e.detail;
  278. that.form.avatarUrl = avatarUrl; // 临时渲染
  279. },
  280. // 通过微信资料修改个人资料
  281. updateUserInfoByWeixin() {
  282. // 上传头像
  283. // vk.callFunctionUtil.uploadFile({
  284. // title: '上传头像中...',
  285. // filePath: that.form.avatarUrl,
  286. // suffix: 'png', // 不传suffix会自动获取,但H5环境下获取不到后缀,但可以通过file.name 获取
  287. // provider: 'unicloud',
  288. // success(res) {
  289. // // 上传成功
  290. // vk.userCenter.updateUser({
  291. // data: {
  292. // avatar: res.url,
  293. // nickname: that.form.nickname
  294. // },
  295. // success: data => {
  296. // // 成功后的逻辑
  297. // that.editWeixinUserInfoPopupShow = false;
  298. // // 写入本次修改时间
  299. // let currentTime = Date.parse(new Date()) / 1000; // 秒级
  300. // vk.vuex.set('$user.history.lastEditUserInfoTime', currentTime);
  301. // vk.alert('保存成功');
  302. // }
  303. // });
  304. // }
  305. // });
  306. },
  307. // 检测版本更新
  308. checkUpdate() {
  309. const updateManager = uni.getUpdateManager();
  310. updateManager.onCheckForUpdate(function(res) {
  311. // 请求完新版本信息的回调
  312. console.log(res.hasUpdate);
  313. if (!res.hasUpdate) {
  314. uni.$msg('当前已是最新版本');
  315. }
  316. });
  317. updateManager.onUpdateReady(function(res) {
  318. uni.showModal({
  319. title: '更新提示',
  320. content: '新版本已经准备好,是否重启应用?',
  321. success(res) {
  322. if (res.confirm) {
  323. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  324. updateManager.applyUpdate();
  325. }
  326. }
  327. });
  328. });
  329. updateManager.onUpdateFailed(function(res) {
  330. // 新的版本下载失败
  331. });
  332. },
  333. // 退出登录
  334. logout() {
  335. uni.showModal({
  336. title: '提示',
  337. content: '确定退出登录?',
  338. success(res) {
  339. if (res.confirm) {
  340. uni.removeStorageSync('MD_userInfo')
  341. uni.removeStorageSync('MD_token')
  342. uni.reLaunch({
  343. url: '/pages/index/index'
  344. })
  345. }
  346. }
  347. })
  348. }
  349. }
  350. };
  351. </script>
  352. <style lang="scss">
  353. .page {
  354. min-height: calc(100vh - 45px);
  355. }
  356. .popup-body {
  357. display: flex;
  358. flex-direction: column;
  359. align-items: center;
  360. .choose-avatar {
  361. position: relative;
  362. }
  363. }
  364. // 菜单列表
  365. .menu-list-wrap {
  366. display: flex;
  367. flex-direction: column;
  368. align-items: flex-start;
  369. background-color: #fff;
  370. padding: 32rpx;
  371. width: 100%;
  372. margin-bottom: 20rpx;
  373. border-radius: 10rpx;
  374. position: relative;
  375. .menu-item {
  376. width: 100%;
  377. display: flex;
  378. align-items: center;
  379. justify-content: space-between;
  380. padding: 20rpx 0;
  381. .menu-title-wrap {
  382. display: flex;
  383. align-items: center;
  384. .title {
  385. display: flex;
  386. align-items: center;
  387. font-size: $u-p;
  388. }
  389. }
  390. }
  391. }
  392. .scoped-btn-to-div {
  393. background: transparent;
  394. border: 0;
  395. outline:0px;
  396. -webkit-appearance: none;
  397. &::after {
  398. display: none;
  399. }
  400. }
  401. .scoped-scan-img {
  402. width: 100%;
  403. }
  404. </style>