setting.vue 9.9 KB

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