金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1236 lines
33 KiB

  1. <template>
  2. <view id="personalCenter" v-if="accountInfoInit">
  3. <lf-nav title="我的"></lf-nav>
  4. <!--uto不用-->
  5. <view class="pc-banner" :style="'background: ' + config.mainColor" @tap="jumpImg" v-if="accountInfo && accountInfo.miniProgram.appId != 'wx53d4c6e7b2c13a13'">
  6. <view class="bg">
  7. <view class="ban-item-l" v-if="token">
  8. <view class="user-avatar">
  9. <image :src="detail.avatar"></image>
  10. </view>
  11. <view class="user-text">
  12. <view class="nick-name">{{detail.nick_name}}</view>
  13. </view>
  14. </view>
  15. <view class="ban-item-r" v-if="token">
  16. <!--<view class="private-letter">
  17. <view class="iconfont icon&#45;&#45;xiaoxi"></view>
  18. <view class="dot"></view>
  19. </view>-->
  20. <!-- <view class="up-grade" @tap.stop="jumpVip">
  21. <view class="icon-img">
  22. <image src="https://ibrand-miniprogram.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E4%BC%9A%E5%91%98.png"></image>
  23. </view>
  24. <view class="vip-copy">
  25. <view class="pretty">VIP</view>
  26. <view class="up">升级领特权</view>
  27. </view>
  28. </view> -->
  29. </view>
  30. <view class="iconfont icon-shezhi setting">
  31. </view>
  32. <view class="unlogin" v-if="!token">
  33. 登录/注册
  34. </view>
  35. </view>
  36. </view>
  37. <!--uni-app-h5-->
  38. <!-- #ifdef H5 -->
  39. <view class="pc-banner" :style="'background: ' + config.mainColor" @tap="jumpImg">
  40. <view class="bg">
  41. <view class="ban-item-l" v-if="token">
  42. <view class="user-avatar">
  43. <image :src="detail.avatar"></image>
  44. </view>
  45. <view class="user-text">
  46. <view class="nick-name">{{detail.nick_name}}</view>
  47. <!-- <view class="vip-text">
  48. <view class="vip-grade">V{{detail.grade}}</view>
  49. <view class="vip-name" v-if="detail.is_agent">{{detail.agent_name}}</view>
  50. <view class="vip-name svip" v-if="detail.vip">
  51. <block v-if="detail.vip.plan.level == 1">
  52. VIP
  53. </block>
  54. <block v-if="detail.vip.plan.level == 2">
  55. SVIP
  56. </block>
  57. <block v-if="detail.vip.plan.level == 3">
  58. SVIP+
  59. </block>
  60. </view>
  61. </view> -->
  62. </view>
  63. </view>
  64. <view class="ban-item-r" v-if="token">
  65. <!--<view class="private-letter">
  66. <view class="iconfont icon&#45;&#45;xiaoxi"></view>
  67. <view class="dot"></view>
  68. </view>-->
  69. <!-- <view class="up-grade" @tap.stop="jumpVip">
  70. <view class="icon-img">
  71. <image src="https://ibrand-miniprogram.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E4%BC%9A%E5%91%98.png"></image>
  72. </view>
  73. <view class="vip-copy">
  74. <view class="pretty">VIP</view>
  75. <view class="up">升级领特权</view>
  76. </view>
  77. </view> -->
  78. </view>
  79. <view class="iconfont icon-shezhi setting">
  80. </view>
  81. <view class="unlogin" v-if="!token">
  82. 登录/注册
  83. </view>
  84. </view>
  85. </view>
  86. <!-- #endif -->
  87. <!-- #ifdef APP-PLUS -->
  88. <view class="pc-banner" :style="'background: ' + config.mainColor" @tap="jumpImg">
  89. <view class="bg">
  90. <view class="ban-item-l" v-if="token">
  91. <view class="user-avatar">
  92. <image :src="detail.avatar"></image>
  93. </view>
  94. <view class="user-text">
  95. <view class="nick-name">{{detail.nick_name}}</view>
  96. </view>
  97. </view>
  98. <view class="ban-item-r" v-if="token">
  99. </view>
  100. <view class="iconfont icon-shezhi setting">
  101. </view>
  102. <view class="unlogin" v-if="!token">
  103. 登录/注册
  104. </view>
  105. </view>
  106. </view>
  107. <!-- #endif -->
  108. <!--uto专用-->
  109. <view class="pc-banner uto-banner" @tap="jumpImg" v-if="accountInfo && accountInfo.miniProgram.appId == 'wx53d4c6e7b2c13a13'">
  110. <view class="bg">
  111. <view class="ban-item-l" v-if="token">
  112. <view class="user-avatar">
  113. <image :src="detail.avatar"></image>
  114. </view>
  115. <view class="user-text">
  116. <view class="nick-name">{{detail.nick_name}}</view>
  117. <view class="vip-text">
  118. <view class="vip-grade">V{{detail.grade}}</view>
  119. <view class="vip-name" v-if="detail.is_agent">{{detail.agent_name}}</view>
  120. <view class="vip-name svip" v-if="detail.vip">
  121. <block v-if="detail.vip.plan.level == 1">
  122. VIP
  123. </block>
  124. <block v-if="detail.vip.plan.level == 2">
  125. SVIP
  126. </block>
  127. <block v-if="detail.vip.plan.level == 3">
  128. SVIP+
  129. </block>
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. <view class="ban-item-r" v-if="token">
  135. <!--<view class="private-letter">
  136. <view class="iconfont icon&#45;&#45;xiaoxi"></view>
  137. <view class="dot"></view>
  138. </view>-->
  139. <view class="up-grade" @tap.stop="jumpVip">
  140. <view class="icon-img">
  141. <image src="https://ibrand-miniprogram.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E4%BC%9A%E5%91%98.png"></image>
  142. </view>
  143. <view class="vip-copy">
  144. <view class="pretty">VIP</view>
  145. <view class="up">升级领特权</view>
  146. </view>
  147. </view>
  148. </view>
  149. <view class="iconfont icon-shezhi setting">
  150. </view>
  151. <view class="unlogin" v-if="!token">
  152. 登录/注册
  153. </view>
  154. </view>
  155. </view>
  156. <view class="binding__phone" @tap="jumpPhone" v-if="!detail.mobile && token && init">
  157. <i class="iconfont icon-warning"></i>
  158. <view class="phone-text">应国家监管要求会员账户需绑定手机号码</view>
  159. <i class="iconfont icon-Chevron"></i>
  160. </view>
  161. <!-- #ifdef MP-WEIXIN -->
  162. <button class="binding__phone binding__user" open-type="getUserInfo" @getuserinfo="bindUserInfo" v-if="!detail.user_info_fill && token && init">
  163. <i class="iconfont icon-warning"></i>
  164. <view class="phone-text">请完善个人信息</view>
  165. </button>
  166. <!-- #endif -->
  167. <!-- #ifdef APP-PLUS -->
  168. <button class="binding__phone binding__user" @tap="bindappUserInfo" v-if="!detail.user_info_fill && token && init">
  169. <i class="iconfont icon-warning"></i>
  170. <view class="phone-text">请完善个人信息</view>
  171. </button>
  172. <!-- #endif -->
  173. <!--优惠券UTO专用-->
  174. <view class="new-coupons-box" :style="'top: ' + top + '; margin-bottom: ' + bottom + ';'" v-if="accountInfo && accountInfo.miniProgram.appId == 'wx53d4c6e7b2c13a13'">
  175. <view class="top-item">
  176. <view class="info mx-1px-right" @tap="jumpBalance">
  177. <view class="balance">{{newdetail.balance || 0}}</view>
  178. <view class="txt">余额</view>
  179. </view>
  180. <view class="info" data-url="/pages/point/index/index" @tap="jumpItem">
  181. <view class="balance">{{newdetail.point || 0}}</view>
  182. <view class="txt">可用积分</view>
  183. </view>
  184. </view>
  185. <view class="bottom-item">
  186. <view class="bg-img" data-url="/pages/coupon/index/index" @tap="jumpItem">
  187. <view class="title">
  188. 优惠券
  189. </view>
  190. <view class="number">
  191. X {{newdetail.coupon || 0}}
  192. </view>
  193. </view>
  194. </view>
  195. </view>
  196. <view class="all-orders">
  197. <view class="order-header mx-1px-bottom" data-status="0" @tap="jump">
  198. <view class="order-text">全部订单</view>
  199. <view class="iconfont icon-Chevron"></view>
  200. </view>
  201. <view class="order-content">
  202. <view class="item" data-status="1" @tap="jump">
  203. <view class="iconfont icon--daifukuan"></view>
  204. <view>待付款</view>
  205. <view class="position-num" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" v-if="token && newdetail.newCount">{{newdetail.newCount}}</view>
  206. </view>
  207. <view class="item" data-status="2" @tap="jump">
  208. <view class="iconfont icon--daifahuo"></view>
  209. <view>待发货</view>
  210. <view class="position-num" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" v-if="token && newdetail.paidCount">{{newdetail.paidCount}}</view>
  211. </view>
  212. <view class="item" data-status="3" @tap="jump">
  213. <view class="iconfont icon--daishouhuo"></view>
  214. <view>待收货</view>
  215. <view class="position-num" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" v-if="token && newdetail.deliveredCount">{{newdetail.deliveredCount}}</view>
  216. </view>
  217. <!--uto不用-->
  218. <view class="item" @tap="jumpComment">
  219. <view class="iconfont icon--daipingjia"></view>
  220. <view>待评价</view>
  221. <view class="position-num" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" v-if="token && newdetail.receiveCount">{{newdetail.receiveCount}}</view>
  222. </view>
  223. <view class="item" @tap="jumpAfterSales">
  224. <view class="iconfont icon-shouhou"></view>
  225. <view>售后</view>
  226. </view>
  227. </view>
  228. </view>
  229. <!--uto不用-->
  230. <view class="info-detail" v-if="accountInfo && accountInfo.miniProgram.appId != 'wx53d4c6e7b2c13a13'">
  231. <!-- <view class="item" @tap="jumpFavor">
  232. <view class="number"><text>{{newdetail.favCount || 0}}</text></view>
  233. <view>收藏</view>
  234. </view> -->
  235. <view class="item" @tap="jumpAddress">
  236. <view v-if="token">
  237. <view class="number"><text>{{newdetail.addressCount || 0}}</text></view>
  238. </view>
  239. <view v-else>
  240. <view class="number"><text>0</text></view>
  241. </view>
  242. <view>地址</view>
  243. </view>
  244. <view class="item" @tap="jumpBalance">
  245. <view v-if="token">
  246. <view class="number"><text>{{newdetail.balance || 0}}</text></view>
  247. </view>
  248. <view v-else>
  249. <view class="number"><text>0</text></view>
  250. </view>
  251. <view>余额</view>
  252. </view>
  253. <view class="item" data-url="/pages/point/index/index" @tap="jumpItem">
  254. <view v-if="token">
  255. <view class="number"><text>{{newdetail.point || 0}}</text></view>
  256. </view>
  257. <view v-else>
  258. <view class="number"><text>0</text></view>
  259. </view>
  260. <view>积分</view>
  261. </view>
  262. <view class="item" data-url="/pages/coupon/index/index" @tap="jumpItem">
  263. <view v-if="token">
  264. <view class="number"><text>{{newdetail.couponCount || 0}}</text></view>
  265. </view>
  266. <view v-else>
  267. <view class="number"><text>0</text></view>
  268. </view>
  269. <view>优惠券</view>
  270. </view>
  271. </view>
  272. <!-- #ifdef H5 -->
  273. <view class="info-detail">
  274. <!-- <view class="item" @tap="jumpFavor">
  275. <view class="number"><text>{{newdetail.favCount || 0}}</text></view>
  276. <view>收藏</view>
  277. </view> -->
  278. <view class="item" @tap="jumpAddress">
  279. <view v-if="token">
  280. <view class="number"><text>{{newdetail.addressCount || 0}}</text></view>
  281. </view>
  282. <view v-else>
  283. <view class="number"><text>0</text></view>
  284. </view>
  285. <view>地址</view>
  286. </view>
  287. <view class="item" @tap="jumpBalance">
  288. <view v-if="token">
  289. <view class="number"><text>{{newdetail.balance || 0}}</text></view>
  290. </view>
  291. <view v-else>
  292. <view class="number"><text>0</text></view>
  293. </view>
  294. <view>余额</view>
  295. </view>
  296. <view class="item" data-url="/pages/point/index/index" @tap="jumpItem">
  297. <view v-if="token">
  298. <view class="number"><text>{{newdetail.point || 0}}</text></view>
  299. </view>
  300. <view v-else>
  301. <view class="number"><text>0</text></view>
  302. </view>
  303. <view>积分</view>
  304. </view>
  305. <view class="item" data-url="/pages/coupon/index/index" @tap="jumpItem">
  306. <view v-if="token">
  307. <view class="number"><text>{{newdetail.couponCount || 0}}</text></view>
  308. </view>
  309. <view v-else>
  310. <view class="number"><text>0</text></view>
  311. </view>
  312. <view>优惠券</view>
  313. </view>
  314. </view>
  315. <!-- #endif -->
  316. <!-- #ifdef APP-PLUS -->
  317. <view class="info-detail">
  318. <!-- <view class="item" @tap="jumpFavor">
  319. <view class="number"><text>{{newdetail.favCount || 0}}</text></view>
  320. <view>收藏</view>
  321. </view> -->
  322. <view class="item" @tap="jumpAddress">
  323. <view v-if="token" class="number"><text>{{newdetail.addressCount || 0}}</text></view>
  324. <view v-else class="number">0</view>
  325. <view>地址</view>
  326. </view>
  327. <view class="item" @tap="jumpBalance">
  328. <view v-if="token" class="number"><text>{{newdetail.balance || 0}}</text></view>
  329. <view v-else class="number">0</view>
  330. <view>余额</view>
  331. </view>
  332. <view class="item" data-url="/pages/point/index/index" @tap="jumpItem">
  333. <view v-if="token" class="number"><text>{{newdetail.point || 0}}</text></view>
  334. <view v-else class="number">0</view>
  335. <view>积分</view>
  336. </view>
  337. <view class="item" data-url="/pages/coupon/index/index" @tap="jumpItem">
  338. <view v-if="token" class="number"><text>{{newdetail.couponCount || 0}}</text></view>
  339. <view v-else class="number">0</view>
  340. <view>优惠券</view>
  341. </view>
  342. </view>
  343. <!-- #endif -->
  344. <view v-if="token">
  345. <view class="section-serve" v-if="initInfo && initInfo.need_sign_in || initInfo && initInfo.point_mall_status ||initInfo&& initInfo.built_sns_status || detail.distribution_status">
  346. <view class="title mx-1px-bottom">我的服务</view>
  347. <view class="server-box mx-1px-bottom">
  348. <!--uto不用-->
  349. <view class="item" @tap="jumpCollar" v-if="initInfo && initInfo.need_sign_in">
  350. <view class="iconfont icon-daqiaqiandao info"></view>
  351. <view>打卡签到</view>
  352. </view>
  353. <view class="item" @tap="jumpPoint" v-if="initInfo && initInfo.point_mall_status">
  354. <view class="iconfont icon--jifen info mall"></view>
  355. <view>积分商城</view>
  356. </view>
  357. <!--<view class="item" @tap="jumpTravel" v-if="initInfo.built_sns_status">-->
  358. <!--<view class="iconfont icon-mifenquan info mi"></view>-->
  359. <!--<view>我的{{initInfo.built_sns_title}}</view>-->
  360. <!--</view>-->
  361. <view class="item" v-if="detail.distribution_status == 1 && detail.is_agent == 1" data-url="/pages/distribution/distributionCenter/distributionCenter"
  362. @tap="jumpItem">
  363. <view class="iconfont icon--fenxiaozhongxin info"></view>
  364. <view>分销中心</view>
  365. </view>
  366. <view class="item" v-if="detail.distribution_status == 1 && detail.distribution_recruit_status == 1 && detail.is_agent == 0"
  367. data-url="/pages/distribution/applyDistribution/applyDistribution" @tap="jumpItem">
  368. <view class="iconfont icon--fenxiaozhongxin info"></view>
  369. <view>加入分销</view>
  370. </view>
  371. <view class="item" v-if="detail.wecaht_group" data-url="/pages/user/gidList/gidList" @tap="jumpItem">
  372. <view class="iconfont icon--weixin info mi"></view>
  373. <view>群列表</view>
  374. </view>
  375. <view class="item" @tap="changeAttention">
  376. <view class="iconfont icon-service info mi"></view>
  377. <view>联系客服</view>
  378. </view>
  379. <!-- <view class="item" data-url="/pages/user/find/find" @tap="jumpItem">
  380. <view class="iconfont icon-faxian info mall"></view>
  381. <view>素材库</view>
  382. </view> -->
  383. <view class="item" data-url="/pages/bargain/list/list" @tap="jumpItem">
  384. <view class="iconfont icon-daqiaqiandao info"></view>
  385. <view>我的砍价</view>
  386. </view>
  387. <view class="item" @tap="changeAgreement">
  388. <view class="iconfont icon-question-circle-o info agree"></view>
  389. <view>关于果酱</view>
  390. </view>
  391. </view>
  392. </view>
  393. </view>
  394. <view class="swiper-adv" v-if="img_list.length">
  395. <swiper indicator-dots="true" autoplay="true" circular="true">
  396. <swiper-item :data-url="item.url" @tap="jumpOpenVip" v-for="(item, index) in img_list" :key="index">
  397. <image :src="item.img"></image>
  398. </swiper-item>
  399. </swiper>
  400. </view>
  401. <view style="text-align: center;padding: 10px 0 20px 0;font-size: 12px;color:#6A6A6A"><view class="copy-right">
  402. Copyright@2019-2020
  403. <view>果酱社区 版权所有</view>
  404. </view></view>
  405. <!--弹出客服-->
  406. <view class="maks" :class="show_attention ? 'cur' : ''" @tap="changeAttention">
  407. </view>
  408. <view class="attention-WeChat" :class="show_attention ? 'cur' : ''">
  409. <view class="service-box">
  410. <view class="code item" @tap="previewImage">
  411. <image mode="widthFix" :src="(service_info && service_info.online_service_self&& service_info.online_service_self.qr_code)
  412. ?service_info.online_service_self.qr_code:''"
  413. alt></image>
  414. <view class="text">
  415. 保存二维码用微信识别添加
  416. </view>
  417. </view>
  418. <view class="item phone" @tap="callPhone">
  419. <view class="phone-text">
  420. <image mode="widthFix" :src="(service_info && service_info.online_service_self && service_info.online_service_self.qr_code)
  421. ?service_info.online_service_self.qr_code:''"
  422. alt></image>
  423. <view class="phone-warp">
  424. <i class="iconfont icon-dianhua"></i>
  425. <view class="phone-num">{{service_info && service_info.online_service_self && service_info.online_service_self.phone
  426. ?service_info.online_service_self.phone:''}}</view>
  427. <view>点击电话咨询客服</view>
  428. </view>
  429. </view>
  430. <view>
  431. {{(service_info && service_info.online_service_self && service_info.online_service_self.time)
  432. ?service_info.online_service_self.time:''}}
  433. </view>
  434. </view>
  435. </view>
  436. </view>
  437. <view class="is_birthday" v-if="is_showBirth">
  438. <!-- 生日有礼 -->
  439. <birthday :gift-data="giftData" @close="changeBirthday"></birthday>
  440. </view>
  441. <lf-tabbar></lf-tabbar>
  442. </view>
  443. </template>
  444. <script>
  445. import {
  446. pageLogin,
  447. GetUrl,
  448. isBirthday,
  449. // #ifdef MP-WEIXIN
  450. autoLogin
  451. // #endif
  452. } from '@/common/js/utils.js';
  453. import birthday from '@/components/birthday/birthday.vue';
  454. import lfNav from '@/components/lf-nav/lf-nav.vue';
  455. import lfTabbar from '@/components/lf-tabbar/lf-tabbar.vue';
  456. var app = getApp();
  457. export default {
  458. data() {
  459. return {
  460. detail: "",
  461. newdetail: "",
  462. token: "",
  463. code: '',
  464. shop_id: '',
  465. unionInFo: '',
  466. openInFo: '',
  467. init: false,
  468. config: '',
  469. author: '',
  470. initInfo: {
  471. need_sign_in: ''
  472. },
  473. accountInfo: '',
  474. accountInfoInit: false,
  475. top: 13,
  476. bottom: '-13px',
  477. show_attention: false,
  478. img_list: "",
  479. service_info: '',
  480. giftData:'',//生日有礼的数据
  481. is_showBirth:false,//是否显示生日礼
  482. };
  483. },
  484. components:{
  485. birthday,
  486. lfNav,
  487. lfTabbar
  488. },
  489. onLoad(e) {
  490. var accountInfo = '';
  491. // #ifdef MP-WEIXIN
  492. var accountInfo = wx.getAccountInfoSync();
  493. // #endif
  494. this.accountInfo = accountInfo;
  495. this.accountInfoInit = true
  496. this.inits(e);
  497. this.getCenterList();
  498. },
  499. onShow() {
  500. // 第三方平台配置颜色
  501. var bgConfig = this.$cookieStorage.get('globalConfig') || '';
  502. var initInfo = this.$cookieStorage.get('init');
  503. this.config = bgConfig;
  504. this.initInfo = initInfo;
  505. this.author = initInfo && initInfo.other_technical_support ? initInfo.other_technical_support : '';
  506. if (!bgConfig) {
  507. let extConfig = {};
  508. if (extConfig) {
  509. this.config = extConfig;
  510. }
  511. }
  512. var token = this.$cookieStorage.get('user_token');
  513. this.token = token;
  514. if (token) {
  515. this.getUserInfo();
  516. this.getCenter();
  517. // #ifdef MP-WEIXIN
  518. if (this.code) {
  519. wx.checkSession({
  520. success: res => {
  521. if (res.errMsg != 'checkSession:ok') {
  522. this.getCode();
  523. }
  524. }
  525. });
  526. } else {
  527. this.getCode();
  528. }
  529. // #endif
  530. }
  531. },
  532. methods: {
  533. //点击进入协议页面
  534. changeAgreement(){
  535. wx.navigateTo({
  536. url:"/pages/user/agreement/agreement"
  537. })
  538. },
  539. changeBirthday(){
  540. this.is_showBirth = false;
  541. var gift= this.$cookieStorage.get("birthday_gift");
  542. gift.flag=true;
  543. this.$cookieStorage.set("birthday_gift",gift);
  544. },
  545. changeAttention() {
  546. this.show_attention = !this.show_attention;
  547. },
  548. previewImage() {
  549. wx.previewImage({
  550. current: this.service_info.online_service_self.qr_code,
  551. urls: [this.service_info.online_service_self.qr_code]
  552. });
  553. },
  554. jumpOpenVip(e) {
  555. var url = e.currentTarget.dataset.url;
  556. wx.navigateTo({
  557. url: url
  558. });
  559. },
  560. callPhone() {
  561. wx.makePhoneCall({
  562. phoneNumber: this.service_info.online_service_self.phone
  563. });
  564. },
  565. // app获取用户信息
  566. /* bindappUserInfo(){
  567. // 获取用户信息
  568. var app_info = this.$cookieStorage.get('app_user_info');
  569. console.log('app_info',app_info);
  570. this.updateUserInfo(app_info);
  571. }, */
  572. // 获取初始化数据
  573. inits(e) {
  574. var token = this.$cookieStorage.get('user_token');
  575. var agent_code = '';
  576. if (e.agent_code) {
  577. agent_code = e.agent_code;
  578. }
  579. if (e.scene) {
  580. var scene = decodeURIComponent(e.scene);
  581. var sceneArr = scene.split(',');
  582. if (sceneArr.length > 0) {
  583. agent_code = sceneArr[1];
  584. }
  585. }
  586. this.$http.get({
  587. api: 'api/system/init'
  588. }).then(res => {
  589. if (res.statusCode == 200) {
  590. res = res.data;
  591. if (res.status) {
  592. if (res.data && res.data.other_technical_support) {
  593. this.author = res.data.other_technical_support;
  594. }
  595. this.$cookieStorage.set('init_info', res.data.h5_share);
  596. this.$cookieStorage.set('service_info', res.data.online_service_data);
  597. this.$cookieStorage.set('distribution_valid_time', res.data.distribution_valid_time);
  598. this.$cookieStorage.set('init', res.data);
  599. this.$cookieStorage.set('userName', )
  600. var service_info = this.$cookieStorage.get('service_info');
  601. this.service_info = service_info;
  602. this.setCode(e);
  603. // #ifdef MP-WEIXIN
  604. if (agent_code && res.data.mini_program_login_type == 'default' && token == '') {
  605. wx.showLoading({
  606. title: '正在自动登录',
  607. mask: true
  608. });
  609. wx.login({
  610. success: res => {
  611. if (res.code) {
  612. autoLogin(res.code, agent_code).then(res => {
  613. if (res.status) {
  614. if (res.data.access_token) {
  615. var access_token = res.data.token_type + ' ' + res.data.access_token;
  616. this.is_login = access_token;
  617. this.token = access_token;
  618. if(this.is_login){
  619. this.getUserInfo();
  620. this.getCenter();
  621. }
  622. if (this.code) {
  623. wx.checkSession({
  624. success: res => {
  625. if (res.errMsg != 'checkSession:ok') {
  626. this.getCode();
  627. }
  628. }
  629. });
  630. } else {
  631. this.getCode();
  632. }
  633. }
  634. if (res.data.open_id) {
  635. wx.reLaunch({
  636. url: '/pages/user/agentlogin/agentlogin?agent_code=' + agent_code + '&open_id=' + res.data.open_id +
  637. '&url=' + getUrl() + '&is_tab=true'
  638. });
  639. }
  640. }
  641. wx.hideLoading();
  642. }, err => {
  643. wx.hideLoading();
  644. });
  645. } else {
  646. wx.showToast({
  647. title: '获取code失败',
  648. icon: 'none'
  649. });
  650. }
  651. }
  652. });
  653. }
  654. // #endif
  655. // #ifdef H5
  656. if(agent_code && token == ''){
  657. var env = {
  658. isIPad: /ipad/i.test(window.navigator.userAgent),
  659. isIphone: /iphone|ipad|ipod/i.test(window.navigator.userAgent),
  660. isWechat: /MicroMessenger/i.test(window.navigator.userAgent)
  661. }
  662. if(env.isWechat){
  663. if(e.openid){
  664. this.$cookieStorage.set('openid',e.openid)
  665. }
  666. var openid = this.$cookieStorage.get('openid') || e.openid;
  667. if(openid){
  668. this.postNewQuickLogin(openid,agent_code);
  669. } else{
  670. let origin = window.location.origin;
  671. var url = origin+'/pages/user/personal/personal?agent_code='+agent_code;
  672. window.location.href = this.$config.GLOBAL.baseUrl+'oauth/wxOauth?redirect_url='+encodeURIComponent(url);
  673. }
  674. } else{
  675. wx.navigateTo({
  676. url:'/pages/user/loginType/loginType'
  677. })
  678. }
  679. }
  680. // #endif
  681. } else {
  682. this.setCode(e);
  683. }
  684. } else {
  685. this.setCode(e);
  686. }
  687. });
  688. },
  689. postNewQuickLogin(open_id,agent_code){
  690. wx.showLoading({
  691. title: '正在登录',
  692. mask: true
  693. });
  694. this.$http.post({
  695. api:'api/oauth/newQuickLogin',
  696. data:{
  697. open_id:open_id,
  698. agent_code:agent_code
  699. }
  700. }).then(res=>{
  701. res = res.data;
  702. if(res.status){
  703. if(res.data.access_token){
  704. var access_token = res.data.token_type + ' ' + res.data.access_token;
  705. var expires_in = res.data.expires_in || 315360000;
  706. this.$cookieStorage.set("user_token", access_token, expires_in);
  707. //如果用户没有绑定手机号
  708. if(res.data.has_bind_mobile == 0){
  709. wx.reLaunch({
  710. url:'/pages/user/bindingphone/bindingphone'
  711. })
  712. } else{
  713. this.token = this.$cookieStorage.get('user_token');
  714. if(this.token){
  715. this.getUserInfo();
  716. this.getCenter();
  717. }
  718. }
  719. } else{
  720. wx.showModal({
  721. content: res.message || '请求失败,请重试',
  722. showCancel: false
  723. });
  724. }
  725. } else{
  726. wx.showModal({
  727. content: res.message || '请求失败,请重试',
  728. showCancel: false
  729. });
  730. }
  731. wx.hideLoading()
  732. }).catch(rej=>{
  733. wx.showModal({
  734. content: rej.message || '请求失败,请重试',
  735. showCancel: false
  736. });
  737. wx.hideLoading()
  738. })
  739. },
  740. setCode(e) {
  741. const timeMap = {
  742. y: 31536000000,
  743. m: 2592000000,
  744. d: 86400000,
  745. h: 3600000,
  746. n: 60000,
  747. s: 1000
  748. }; // 默认有效期为7天
  749. var valid_time = "";
  750. var clerk_id = e.clerk_id || "";
  751. var shop_id = e.shop_id || "";
  752. var agent_code = e.agent_code || '';
  753. if (e.scene) {
  754. var scene = decodeURIComponent(e.scene);
  755. var sceneArr = scene.split(',');
  756. if (sceneArr.length > 0) {
  757. agent_code = sceneArr[0];
  758. }
  759. }
  760. var cook_shop_id = this.$cookieStorage.get('shop_id');
  761. if (!this.$cookieStorage.get('distribution_valid_time')) {
  762. valid_time = 10080;
  763. } else {
  764. valid_time = this.$cookieStorage.get('distribution_valid_time');
  765. }
  766. let timeStamp = new Date().getTime();
  767. timeStamp += timeMap.n * valid_time; // 当url上shop_id与缓存中shop_id不一致时,需要清除clerk_id。以此保证shop_id与clerk_id对应
  768. var cook_clerk_id = this.$cookieStorage.get('clerk_id');
  769. if (cook_shop_id != shop_id && cook_clerk_id) {
  770. this.$cookieStorage.clear('clerk_id');
  771. }
  772. if (agent_code) {
  773. this.$cookieStorage.set('agent_code', agent_code, valid_time + 'n'); // 如果有agent_code就将这次进入的时间缓存
  774. this.$cookieStorage.set('agent_code_time', timeStamp, valid_time + 'n'); // 如果有agent_code并且有coupon_agent_code就将coupon_agent_code清除,保证agent_code为第一位
  775. if (this.$cookieStorage.get('coupon_agent_code')) {
  776. this.$cookieStorage.clear('coupon_agent_code');
  777. }
  778. }
  779. if (clerk_id) {
  780. this.$cookieStorage.set('clerk_id', clerk_id, valid_time + 'n');
  781. }
  782. if (shop_id) {
  783. this.$cookieStorage.set('shop_id', shop_id, valid_time + 'n'); // 如果有shop_id就将这次进入的时间缓存
  784. this.$cookieStorage.set('shop_id_time', timeStamp, valid_time + 'n');
  785. }
  786. },
  787. jumpAuthor() {
  788. wx.navigateTo({
  789. url: '/pages/index/author/author'
  790. });
  791. },
  792. getCode() {
  793. wx.login({
  794. success: res => {
  795. if (res.code) {
  796. this.code = res.code;
  797. }
  798. }
  799. });
  800. },
  801. jumpItem(e) {
  802. if (!this.token) {
  803. return this.jumpLogin();
  804. }
  805. var url = e.currentTarget.dataset.url;
  806. wx.navigateTo({
  807. url: url
  808. });
  809. },
  810. jumpLogin() {
  811. wx.navigateTo({
  812. url: '/pages/user/register/register'
  813. });
  814. },
  815. jumpPhone() {
  816. wx.navigateTo({
  817. url: '/pages/user/phone/phone'
  818. });
  819. },
  820. jumpFavor() {
  821. if (!this.token) {
  822. return this.jumpLogin();
  823. }
  824. wx.navigateTo({
  825. url: '/pages/favorite/index/index'
  826. });
  827. },
  828. jumpPoint() {
  829. if (!this.token) {
  830. return this.jumpLogin();
  831. }
  832. wx.navigateTo({
  833. url: '/pages/pointStore/index/index'
  834. });
  835. },
  836. jumpTravel() {
  837. if (!this.token) {
  838. return this.jumpLogin();
  839. }
  840. wx.navigateTo({
  841. url: '/pages/travels/myTravel/myTravel'
  842. });
  843. },
  844. getUserInfo() {
  845. this.$http.get({
  846. api: 'api/me',
  847. header: {
  848. Authorization: this.$cookieStorage.get('user_token')
  849. }
  850. }).then(res => {
  851. if (res.data.status) {
  852. if (!res.data.data.mobile || !res.data.data.user_info_fill) {
  853. this.top = 0;
  854. this.bottom = '5px';
  855. }
  856. this.detail = res.data.data;
  857. this.init = true;
  858. // 把头像和昵称存起来,签到页面直接获取
  859. this.$cookieStorage.set('userInfoImg', res.data.data.avatar)
  860. this.$cookieStorage.set('userInfoName', res.data.data.nick_name)
  861. if(!res.data.data.gift_is_receive){
  862. isBirthday().then(()=>{
  863. if(this.$cookieStorage.get("birthday_gift")){
  864. var giftData=this.$cookieStorage.get("birthday_gift").data;
  865. this.giftData = giftData;
  866. this.is_showBirth = true;
  867. }
  868. });
  869. }
  870. // #ifdef APP-PLUS
  871. if(res.data.data.user_info_fill == 0){
  872. var app_info = this.$cookieStorage.get('app_user_info');
  873. if(app_info){
  874. this.appUpdateInfo(app_info);
  875. }
  876. }
  877. // #endif
  878. }
  879. });
  880. },
  881. jumpAddress() {
  882. if (!this.token) {
  883. return this.jumpLogin();
  884. }
  885. wx.navigateTo({
  886. url: '/pages/address/list/list'
  887. });
  888. },
  889. jumpComment() {
  890. if (!this.token) {
  891. return this.jumpLogin();
  892. }
  893. wx.navigateTo({
  894. url: '/pages/order/comment/comment'
  895. });
  896. },
  897. jumpCollar() {
  898. if (!this.token) {
  899. return this.jumpLogin();
  900. }
  901. wx.navigateTo({
  902. url: '/pages/user/sign/sign'
  903. });
  904. },
  905. jumpBalance() {
  906. if (!this.token) {
  907. return this.jumpLogin();
  908. }
  909. wx.navigateTo({
  910. url: '/pages/recharge/balance/balance'
  911. });
  912. },
  913. jumpNews() {
  914. if (!this.token) {
  915. return this.jumpLogin();
  916. }
  917. wx.navigateTo({
  918. url: '/pages/user/news/news'
  919. });
  920. },
  921. jumpCan() {
  922. wx.navigateTo({
  923. url: '/pages/entity/index/index?shop_id=1'
  924. });
  925. },
  926. jumpDetail() {
  927. wx.navigateTo({
  928. url: '/pages/entity/detail/detail?id=1447&shop_id=1'
  929. });
  930. },
  931. jumpVip() {
  932. if (!this.token) {
  933. return this.jumpLogin();
  934. }
  935. var svip = this.initInfo.vip_plan_status;
  936. var isSvip = this.detail.vip;
  937. if (svip == 1) {
  938. if (isSvip) {
  939. wx.navigateTo({
  940. url: '/pages/user/svip/svip'
  941. });
  942. } else {
  943. wx.navigateTo({
  944. url: '/pages/recharge/index/index'
  945. });
  946. }
  947. } else {
  948. wx.navigateTo({
  949. url: '/pages/card/index/index'
  950. });
  951. }
  952. },
  953. jumpImg() {
  954. if (!this.token) {
  955. return this.jumpLogin();
  956. }
  957. wx.navigateTo({
  958. url: '/pages/user/setting/setting'
  959. });
  960. },
  961. jump(e) {
  962. if (!this.token) {
  963. return this.jumpLogin();
  964. }
  965. var status = e.currentTarget.dataset.status;
  966. wx.navigateTo({
  967. url: '/pages/order/index/index?type=' + status
  968. });
  969. },
  970. jumpAfterSales() {
  971. if (!this.token) {
  972. return this.jumpLogin();
  973. }
  974. wx.navigateTo({
  975. url: '/pages/afterSales/index/index'
  976. });
  977. },
  978. jumpSetting() {
  979. if (!this.token) {
  980. return this.jumpLogin();
  981. }
  982. wx.navigateTo({
  983. url: '/pages/user/out/out'
  984. });
  985. },
  986. bindUserInfo(e) {
  987. if (e.detail.encryptedData) {
  988. e.detail.code = this.code;
  989. this.updateUserInfo(e.detail);
  990. }
  991. },
  992. //app完善信息
  993. appUpdateInfo(data){
  994. wx.showLoading({
  995. title: '完善信息中',
  996. mask: true
  997. });
  998. this.$http.post({
  999. api:'api/users/update/info',
  1000. data:{
  1001. nick_name:data.nickName,
  1002. avatar:data.avatarUrl
  1003. },
  1004. header: {
  1005. Authorization: this.$cookieStorage.get('user_token')
  1006. }
  1007. }).then(res=>{
  1008. res = res.data;
  1009. if(res.status){
  1010. this.getUserInfo()
  1011. } else{
  1012. wx.showModal({
  1013. content: res.message || '请求失败',
  1014. showCancel: false
  1015. });
  1016. }
  1017. wx.hideLoading();
  1018. }).catch(rej=>{
  1019. wx.showModal({
  1020. content: rej.message || '请求失败',
  1021. showCancel: false
  1022. });
  1023. wx.hideLoading();
  1024. })
  1025. },
  1026. updateUserInfo(data) {
  1027. wx.showLoading({
  1028. title: '完善信息中',
  1029. mask: true
  1030. });
  1031. this.$http.get({
  1032. api: 'api/user/bindUserMiniInfo',
  1033. data: data,
  1034. header: {
  1035. Authorization: this.$cookieStorage.get('user_token')
  1036. }
  1037. }).then(res => {
  1038. res = res.data;
  1039. if (res.status) {
  1040. // #ifdef MP-WEIXIN
  1041. this.getUserInfo();
  1042. // #endif
  1043. wx.hideLoading();
  1044. } else {
  1045. wx.showModal({
  1046. content: res.message || '请求失败',
  1047. showCancel: false
  1048. });
  1049. this.getCode();
  1050. wx.hideLoading();
  1051. }
  1052. wx.hideLoading();
  1053. }).catch(rej=>{
  1054. wx.showModal({
  1055. content: rej.message || '请求失败',
  1056. showCancel: false
  1057. });
  1058. wx.hideLoading();
  1059. });
  1060. },
  1061. //获取页面信息
  1062. getCenter() {
  1063. var token = this.$cookieStorage.get('user_token');
  1064. this.$http.get({
  1065. api: 'api/users/ucenter',
  1066. header: {
  1067. Authorization: token
  1068. }
  1069. }).then(res => {
  1070. if (res.data.status) {
  1071. this.newdetail = res.data.data;
  1072. }
  1073. });
  1074. },
  1075. // 获取广告图
  1076. getCenterList() {
  1077. this.$http.get({
  1078. api: 'api/user/center/img_list'
  1079. }).then(res => {
  1080. if (res.statusCode == 200) {
  1081. res = res.data;
  1082. if (res.status) {
  1083. this.img_list = res.data;
  1084. }
  1085. }
  1086. });
  1087. },
  1088. }
  1089. };
  1090. </script>
  1091. <style rel="stylesheet/less" lang="less">
  1092. @import "personal.less";
  1093. </style>