setting.vue 12 KB

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