management.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <template>
  2. <view class="management">
  3. <navbar ref="navbar" :config="config" backColor="#666"></navbar>
  4. <view class="top" @click="goToEdit">
  5. <view class="image">
  6. <image v-if="userInfo.head_photo" :src="userInfo.head_photo" mode=""></image>
  7. <image v-else :src="imgUrl+'/head-on.png'" mode=""></image>
  8. </view>
  9. <view class="name-and-num">
  10. <div>
  11. <view class="name">
  12. {{userInfo.real_name}}
  13. </view>
  14. <view class="num u-text1">
  15. {{userInfo.mobile}}
  16. </view>
  17. </div>
  18. <view class="iconfont">
  19. &#xe6c7;
  20. </view>
  21. </view>
  22. </view>
  23. <view class="distance">
  24. </view>
  25. <view class="content">
  26. <!-- <view class="modify" @click="goToModifyPass">
  27. <view class="password">
  28. 修改密码
  29. </view>
  30. <view class="modif-name">
  31. <text class="iconfont">&#xe6c7;</text>
  32. </view>
  33. </view>
  34. <view class="modify" @click="goToForgetPass">
  35. <view class="password">
  36. 忘记密码
  37. </view>
  38. <view class="modif-name">
  39. <text class="iconfont">&#xe6c7;</text>
  40. </view>
  41. </view> -->
  42. </view>
  43. <view class="distance">
  44. </view>
  45. <view class="address">
  46. <view class="item" @click="goToReplacePhone">
  47. <view class="my-address">
  48. 更换手机号
  49. </view>
  50. <view class="iconfont">&#xe6c7;</view>
  51. </view>
  52. </view>
  53. <view class="address" @click="goPayPassword()">
  54. <view class="item">
  55. <view class="my-address">
  56. 设置支付密码
  57. </view>
  58. <view class="iconfont">&#xe6c7;</view>
  59. </view>
  60. </view>
  61. <!-- <view class="address" @click="addBamks()">
  62. <view class="item">
  63. <view class="my-address">
  64. 管理银行卡
  65. </view>
  66. <view class="iconfont">&#xe6c7;</view>
  67. </view>
  68. </view> -->
  69. <!-- <view class="address">
  70. <view class="item" @click="goToAddressList">
  71. <view class="my-address">
  72. 我的地址
  73. </view>
  74. <view class="iconfont">&#xe6c7;</view>
  75. </view>
  76. </view> -->
  77. <view class="address" @click="goAgreement()">
  78. <view class="item">
  79. <view class="my-address">
  80. 关于我们
  81. </view>
  82. <view class="iconfont">&#xe6c7;</view>
  83. </view>
  84. </view>
  85. <view class="address" @click="goLogout()">
  86. <view class="item">
  87. <view class="my-address">
  88. 注销账户
  89. </view>
  90. <view class="iconfont">&#xe6c7;</view>
  91. </view>
  92. </view>
  93. <view class="address">
  94. <!-- <view class="item" @click="swithcWeChat">
  95. <view class="my-address">
  96. 绑定微信
  97. </view>
  98. <view class="u-flex">
  99. <view class="c_gary" v-if="userInfo.bind_wechat">已绑定</view>
  100. <view class="iconfont">&#xe6c7;</view>
  101. </view>
  102. </view>
  103. <view class="item" @click="switchAlipay()">
  104. <view class="my-address">
  105. 绑定支付宝
  106. </view>
  107. <view class="u-flex">
  108. <view class="c_gary" v-if="userInfo.bind_alipay">已绑定</view>
  109. <view class="iconfont">&#xe6c7;</view>
  110. </view>
  111. </view> -->
  112. <view class="item" @click="getUserInfo('examine')">
  113. <view class="my-address">
  114. 检测更新
  115. </view>
  116. <view class="u-flex">
  117. <view class="c_blue" v-if="userInfo.check_latest_ver">有新版本</view>
  118. <view class="" v-else>{{userInfo.ver}}</view>
  119. <view class="iconfont">&#xe6c7;</view>
  120. </view>
  121. </view>
  122. </view>
  123. <!-- <view class="address">
  124. <view class="item" @click="goAboutLd">
  125. <view class="my-address">
  126. 加入我们
  127. </view>
  128. <view class="iconfont">&#xe6c7;</view>
  129. </view>
  130. <view class="item" @click="goAboutUs">
  131. <view class="my-address">
  132. 关于松河生活平台
  133. </view>
  134. <view class="iconfont">&#xe6c7;</view>
  135. </view>
  136. </view> -->
  137. <!-- <view class="footer">
  138. <view>
  139. Copyright@2021-2030 </view>
  140. <view>广东松河生活平台生物科技有限公司 版权所有
  141. </view>
  142. </view> -->
  143. <view class="sign">
  144. <view class="sign-out" @click="logOut">
  145. 退出登录
  146. </view>
  147. </view>
  148. <u-modal v-model="show" content="确定解除绑定?" show-cancel-button @confirm="unbinding"></u-modal>
  149. </view>
  150. </template>
  151. <script>
  152. import {
  153. myInfo,
  154. logout
  155. } from "@/api/login.js"
  156. export default {
  157. data() {
  158. return {
  159. config: {
  160. back: true, //false是tolbar页面 是则不写
  161. title: '设置',
  162. color: '#1A1A1A',
  163. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  164. backgroundColor: [1, "#fff"],
  165. statusBarFontColor: '#1A1A1A',
  166. },
  167. userInfo: {}, //个人信息
  168. imgUrl: this.$mConfig.staticUrl,
  169. code: null,
  170. AlipayCode: null,
  171. versionCode: 0, //版本号
  172. show: false,
  173. type: null,
  174. AlipayType: 1, //2获取支付宝code 1不获取
  175. }
  176. },
  177. onShow() {
  178. // #ifdef APP-PLUS
  179. plus.runtime.getProperty(plus.runtime.appid, (info) => {
  180. this.versionCode = info.versionCode;
  181. this.getUserInfo()
  182. this.getAlipay()
  183. })
  184. // #endif
  185. // #ifndef APP-PLUS
  186. this.getUserInfo()
  187. // #endif
  188. this.getToken()
  189. },
  190. methods: {
  191. // 支付宝授权回调
  192. getAlipay() {
  193. var args = plus.runtime.arguments;
  194. let argsUrl = decodeURIComponent(args.split('?')[1]).split('=')[1];
  195. if (argsUrl && !this.userInfo.bind_alipay && this.AlipayType == 2) {
  196. // 处理args参数,如直达到某新页面等
  197. // plus.runtime.arguments = {};
  198. // uni.redirectTo({
  199. // url: "/pages/login/login?code=" + argsUrl.code
  200. // });
  201. this.AlipayType = 1
  202. this.code = argsUrl
  203. this.binding(1)
  204. }
  205. },
  206. getToken() {
  207. let token = uni.getStorageSync("apiToken")
  208. if (!token) {
  209. uni.redirectTo({
  210. url: "../../index/personal"
  211. })
  212. }
  213. },
  214. goAboutUs() {
  215. uni.navigateTo({
  216. url: "../homepage/about-us-list"
  217. })
  218. },
  219. goAboutLd() {
  220. uni.navigateTo({
  221. url: "../homepage/aboutLida"
  222. })
  223. },
  224. goLogout(){
  225. uni.navigateTo({
  226. url: "/pages/research/setup/logout"
  227. })
  228. },
  229. // 跳转协议
  230. goAgreement() {
  231. uni.navigateTo({
  232. url: "/pages/protocol/index?code=about-us"
  233. })
  234. },
  235. // 绑定/解绑 微信
  236. swithcWeChat() {
  237. if (this.userInfo.bind_wechat) {
  238. this.show = true;
  239. this.type = 0;
  240. return
  241. }
  242. let that = this;
  243. // uni.getProvider({
  244. // service: 'oauth',
  245. // success: function (res) {
  246. // console.log(res.provider)
  247. // }
  248. // });
  249. uni.login({
  250. provider: 'weixin',
  251. onlyAuthorize: true,
  252. success: function(loginRes) {
  253. that.code = loginRes.code
  254. that.binding(0)
  255. },
  256. complete(e) {
  257. console.log(e)
  258. }
  259. });
  260. },
  261. // 绑定 支付宝
  262. switchAlipay() {
  263. if (this.userInfo.bind_alipay) {
  264. this.show = true;
  265. this.type = 1;
  266. return
  267. }
  268. this.code = null;
  269. // let urls =
  270. // `https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id=${this.$mConfig.AlipayAppid}&scope=auth_userinfo&redirect_uri=${this.$mConfig.redirect_uri}/pages/login`;
  271. // urls = encodeURIComponent(urls); //将地址编码成浏览器访问的格式
  272. // this.AlipayType = 2
  273. // // 判断平台
  274. // if (plus.os.name == 'Android') {
  275. // plus.runtime.openURL(
  276. // 'alipays://platformapi/startapp?appId=20000067&url=' + urls,
  277. // res => {
  278. // //这里写打开URL地址失败后的处理
  279. // uni.showModal({
  280. // content: '本机未检测到对应客户端,是否打开浏览器访问页面?',
  281. // success: function(res) {
  282. // if (res.confirm) {
  283. // //plus.runtime.openURL();
  284. // }
  285. // }
  286. // });
  287. // },
  288. // 'com.eg.android.AlipayGphone'
  289. // );
  290. // } else if (plus.os.name == 'iOS') {
  291. // plus.runtime.openURL(
  292. // 'alipay://platformapi/startapp?appId=20000067&url=' + urls,
  293. // res => {
  294. // console.log(res);
  295. // uni.showModal({
  296. // content: '本机未检测到对应客户端,是否打开浏览器访问页面?',
  297. // success: function(res) {
  298. // if (res.confirm) {
  299. // //plus.runtime.openURL(url);
  300. // }
  301. // }
  302. // });
  303. // },
  304. // 'com.eg.android.AlipayGphone'
  305. // );
  306. // }
  307. let str=encodeURIComponent('apiname=com.alipay.account.auth&app_id=2021003145626363&app_name=mc&auth_type=AUTHACCOUNT&biz_type=openservice&method=alipay.open.auth.sdk.code.get&pid=2088441816745635&product_id=APP_FAST_LOGIN&scope=kuaijie&sign_type=RSA2&target_id=lvzv2022')
  308. let alipayLogin = uni.requireNativePlugin("henter-alipay-login")
  309. alipayLogin.login({
  310. authInfo: 'apiname=com.alipay.account.auth&app_id=2021003145626363&app_name=mc&auth_type=AUTHACCOUNT&biz_type=openservice&method=alipay.open.auth.sdk.code.get&pid=2088441816745635&product_id=APP_FAST_LOGIN&scope=kuaijie&sign_type=RSA2&target_id=lvzv2022&sign='+str,
  311. appScheme: 'lmzc'
  312. },
  313. (r) => {
  314. console.log(r)
  315. if (r.resultStatus == 9000) {
  316. let arr = r.result.split("&");
  317. for (let i = 0; i < arr.length; i++) {
  318. let pair = arr[i].split("=");
  319. if (pair[0] == 'auth_code') {
  320. this.code = pair[1]
  321. this.binding(1)
  322. }
  323. }
  324. }
  325. }
  326. )
  327. },
  328. // 绑定
  329. binding(type) {
  330. let param = {
  331. third_type: type,
  332. code: this.code
  333. }
  334. this.$http.post('/account/userthirdidentity/binding', param).then(res => {
  335. console.log(res)
  336. if (res && res.code == 200) {
  337. uni.showToast({
  338. title: '绑定成功!',
  339. duration: 2000
  340. });
  341. this.getUserInfo()
  342. }
  343. }).catch(e => {
  344. console.log(e)
  345. })
  346. },
  347. // 解绑
  348. unbinding() {
  349. let param = {
  350. third_type: this.type,
  351. }
  352. this.$http.post('/account/userthirdidentity/unbind', param).then(res => {
  353. if (res && res.code == 200) {
  354. uni.showToast({
  355. title: '解绑成功!',
  356. duration: 2000
  357. });
  358. this.getUserInfo()
  359. }
  360. })
  361. },
  362. //退出登录
  363. logOut() {
  364. let that = this
  365. let userInfo = uni.getStorageSync("apiToken")
  366. uni.showModal({
  367. title: '你确定要退出吗?',
  368. success: function(res) {
  369. if (res.confirm) {
  370. that.$http.post(logout)
  371. .then(res => {
  372. if (res && res.code == 200) {
  373. uni.removeStorageSync('token');
  374. that.$mUtil.toast("退出成功")
  375. uni.navigateTo({
  376. url: "../register/login"
  377. })
  378. }
  379. })
  380. } else if (res.cancel) {
  381. console.log('用户点击取消');
  382. }
  383. },
  384. });
  385. },
  386. //获取个人信息
  387. getUserInfo(type) {
  388. // myInfo
  389. // /account/center/setting/info
  390. this.$http.get('/account/center/setting/info', {
  391. number: this.versionCode
  392. }).then(res => {
  393. if (res.code == 200) {
  394. this.userInfo = res.data;
  395. if (type && this.userInfo.check_latest_ver) {
  396. uni.navigateTo({
  397. url: "/pages/protocol/versionUpgrade"
  398. })
  399. } else if (type && !this.userInfo.check_latest_ver) {
  400. uni.showToast({
  401. icon: "none",
  402. title: '已是最新版本!',
  403. duration: 2000
  404. });
  405. }
  406. }
  407. })
  408. },
  409. // //获取更新信息
  410. // getUpdataInfo(){
  411. // this.$http.get('')
  412. // },
  413. //跳转设置页
  414. goToEdit() {
  415. uni.navigateTo({
  416. url: "./edit"
  417. })
  418. },
  419. //忘记密码
  420. goToForgetPass() {
  421. uni.navigateTo({
  422. url: "./forgetPass"
  423. })
  424. },
  425. //跳转我的地址
  426. goToAddressList() {
  427. uni.navigateTo({
  428. url: "../../user/address/addressList"
  429. })
  430. },
  431. //修改密码
  432. goToModifyPass() {
  433. uni.navigateTo({
  434. url: "./modifyPass"
  435. })
  436. },
  437. goToReplacePhone() {
  438. uni.navigateTo({
  439. url: "../register/replacePhone"
  440. })
  441. },
  442. goPayPassword(){
  443. uni.navigateTo({
  444. url: "../pay-password"
  445. })
  446. },
  447. addBamks() {
  448. uni.navigateTo({
  449. url: '/pages/order/banks/list'
  450. })
  451. }
  452. }
  453. }
  454. </script>
  455. <style lang="scss" scoped>
  456. .footer {
  457. margin-top: 500rpx;
  458. text-align: center;
  459. }
  460. .management {
  461. position: relative;
  462. }
  463. .sign {
  464. display: flex;
  465. justify-content: center;
  466. .sign-out {
  467. margin-top: 400rpx;
  468. font-size: 36rpx;
  469. color: #ffffff;
  470. font-weight: 400;
  471. padding: 18rpx 272rpx;
  472. background-color: #3D93FC;
  473. border-radius: 43rpx;
  474. }
  475. }
  476. .address {
  477. padding: 0 30rpx;
  478. .item {
  479. display: flex;
  480. justify-content: space-between;
  481. border-bottom: 1rpx solid #E6E6E6;
  482. padding-bottom: 30rpx;
  483. padding-top: 23rpx;
  484. font-size: 28rpx;
  485. color: #1A1A1A;
  486. font-weight: 400;
  487. }
  488. }
  489. .content {
  490. padding: 0 30rpx;
  491. .modify:last-child {
  492. border-bottom: none;
  493. }
  494. .modify {
  495. display: flex;
  496. justify-content: space-between;
  497. align-items: center;
  498. margin-top: 22rpx;
  499. padding-bottom: 30rpx;
  500. border-bottom: 1rpx solid #E6E6E6;
  501. .password {
  502. font-size: 28rpx;
  503. color: #1A1A1A;
  504. font-weight: 400;
  505. }
  506. .modif-name {
  507. font-size: 28rpx;
  508. font-weight: 400;
  509. color: #1A1A1A;
  510. .iconfont {
  511. margin-left: 14rpx;
  512. }
  513. }
  514. }
  515. }
  516. .distance {
  517. height: 10rpx;
  518. background-color: #F5F5F5;
  519. }
  520. .top {
  521. display: flex;
  522. align-items: center;
  523. padding: 0 30rpx;
  524. margin: 45rpx 0 40rpx 0;
  525. .image {
  526. image {
  527. width: 100rpx;
  528. height: 100rpx;
  529. border-radius: 50%;
  530. }
  531. }
  532. .name-and-num {
  533. margin-left: 18rpx;
  534. flex: 1;
  535. display: flex;
  536. justify-content: space-between;
  537. align-items: center;
  538. width: 572rpx;
  539. .name {
  540. overflow: hidden;
  541. white-space: nowrap;
  542. text-overflow: ellipsis;
  543. width: 300rpx;
  544. font-size: 28rpx;
  545. color: #1A1A1A;
  546. font-weight: 400;
  547. }
  548. .num {
  549. font-size: 24rpx;
  550. color: #999999;
  551. font-weight: 500;
  552. }
  553. }
  554. }
  555. .c_gary {
  556. color: #808080;
  557. }
  558. .c_blue {
  559. color: #0071E2;
  560. }
  561. </style>