金诚优选前端代码
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.

1233 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. </view>
  442. </template>
  443. <script>
  444. import {
  445. pageLogin,
  446. GetUrl,
  447. isBirthday,
  448. // #ifdef MP-WEIXIN
  449. autoLogin
  450. // #endif
  451. } from '@/common/js/utils.js';
  452. import birthday from '@/components/birthday/birthday.vue';
  453. import lfNav from '@/components/lf-nav/lf-nav.vue';
  454. var app = getApp();
  455. export default {
  456. data() {
  457. return {
  458. detail: "",
  459. newdetail: "",
  460. token: "",
  461. code: '',
  462. shop_id: '',
  463. unionInFo: '',
  464. openInFo: '',
  465. init: false,
  466. config: '',
  467. author: '',
  468. initInfo: {
  469. need_sign_in: ''
  470. },
  471. accountInfo: '',
  472. accountInfoInit: false,
  473. top: 13,
  474. bottom: '-13px',
  475. show_attention: false,
  476. img_list: "",
  477. service_info: '',
  478. giftData:'',//生日有礼的数据
  479. is_showBirth:false,//是否显示生日礼
  480. };
  481. },
  482. components:{
  483. birthday,
  484. lfNav
  485. },
  486. onLoad(e) {
  487. var accountInfo = '';
  488. // #ifdef MP-WEIXIN
  489. var accountInfo = wx.getAccountInfoSync();
  490. // #endif
  491. this.accountInfo = accountInfo;
  492. this.accountInfoInit = true
  493. this.inits(e);
  494. this.getCenterList();
  495. },
  496. onShow() {
  497. // 第三方平台配置颜色
  498. var bgConfig = this.$cookieStorage.get('globalConfig') || '';
  499. var initInfo = this.$cookieStorage.get('init');
  500. this.config = bgConfig;
  501. this.initInfo = initInfo;
  502. this.author = initInfo && initInfo.other_technical_support ? initInfo.other_technical_support : '';
  503. if (!bgConfig) {
  504. let extConfig = {};
  505. if (extConfig) {
  506. this.config = extConfig;
  507. }
  508. }
  509. var token = this.$cookieStorage.get('user_token');
  510. this.token = token;
  511. if (token) {
  512. this.getUserInfo();
  513. this.getCenter();
  514. // #ifdef MP-WEIXIN
  515. if (this.code) {
  516. wx.checkSession({
  517. success: res => {
  518. if (res.errMsg != 'checkSession:ok') {
  519. this.getCode();
  520. }
  521. }
  522. });
  523. } else {
  524. this.getCode();
  525. }
  526. // #endif
  527. }
  528. },
  529. methods: {
  530. //点击进入协议页面
  531. changeAgreement(){
  532. wx.navigateTo({
  533. url:"/pages/user/agreement/agreement"
  534. })
  535. },
  536. changeBirthday(){
  537. this.is_showBirth = false;
  538. var gift= this.$cookieStorage.get("birthday_gift");
  539. gift.flag=true;
  540. this.$cookieStorage.set("birthday_gift",gift);
  541. },
  542. changeAttention() {
  543. this.show_attention = !this.show_attention;
  544. },
  545. previewImage() {
  546. wx.previewImage({
  547. current: this.service_info.online_service_self.qr_code,
  548. urls: [this.service_info.online_service_self.qr_code]
  549. });
  550. },
  551. jumpOpenVip(e) {
  552. var url = e.currentTarget.dataset.url;
  553. wx.navigateTo({
  554. url: url
  555. });
  556. },
  557. callPhone() {
  558. wx.makePhoneCall({
  559. phoneNumber: this.service_info.online_service_self.phone
  560. });
  561. },
  562. // app获取用户信息
  563. /* bindappUserInfo(){
  564. // 获取用户信息
  565. var app_info = this.$cookieStorage.get('app_user_info');
  566. console.log('app_info',app_info);
  567. this.updateUserInfo(app_info);
  568. }, */
  569. // 获取初始化数据
  570. inits(e) {
  571. var token = this.$cookieStorage.get('user_token');
  572. var agent_code = '';
  573. if (e.agent_code) {
  574. agent_code = e.agent_code;
  575. }
  576. if (e.scene) {
  577. var scene = decodeURIComponent(e.scene);
  578. var sceneArr = scene.split(',');
  579. if (sceneArr.length > 0) {
  580. agent_code = sceneArr[1];
  581. }
  582. }
  583. this.$http.get({
  584. api: 'api/system/init'
  585. }).then(res => {
  586. if (res.statusCode == 200) {
  587. res = res.data;
  588. if (res.status) {
  589. if (res.data && res.data.other_technical_support) {
  590. this.author = res.data.other_technical_support;
  591. }
  592. this.$cookieStorage.set('init_info', res.data.h5_share);
  593. this.$cookieStorage.set('service_info', res.data.online_service_data);
  594. this.$cookieStorage.set('distribution_valid_time', res.data.distribution_valid_time);
  595. this.$cookieStorage.set('init', res.data);
  596. this.$cookieStorage.set('userName', )
  597. var service_info = this.$cookieStorage.get('service_info');
  598. this.service_info = service_info;
  599. this.setCode(e);
  600. // #ifdef MP-WEIXIN
  601. if (agent_code && res.data.mini_program_login_type == 'default' && token == '') {
  602. wx.showLoading({
  603. title: '正在自动登录',
  604. mask: true
  605. });
  606. wx.login({
  607. success: res => {
  608. if (res.code) {
  609. autoLogin(res.code, agent_code).then(res => {
  610. if (res.status) {
  611. if (res.data.access_token) {
  612. var access_token = res.data.token_type + ' ' + res.data.access_token;
  613. this.is_login = access_token;
  614. this.token = access_token;
  615. if(this.is_login){
  616. this.getUserInfo();
  617. this.getCenter();
  618. }
  619. if (this.code) {
  620. wx.checkSession({
  621. success: res => {
  622. if (res.errMsg != 'checkSession:ok') {
  623. this.getCode();
  624. }
  625. }
  626. });
  627. } else {
  628. this.getCode();
  629. }
  630. }
  631. if (res.data.open_id) {
  632. wx.reLaunch({
  633. url: '/pages/user/agentlogin/agentlogin?agent_code=' + agent_code + '&open_id=' + res.data.open_id +
  634. '&url=' + getUrl() + '&is_tab=true'
  635. });
  636. }
  637. }
  638. wx.hideLoading();
  639. }, err => {
  640. wx.hideLoading();
  641. });
  642. } else {
  643. wx.showToast({
  644. title: '获取code失败',
  645. icon: 'none'
  646. });
  647. }
  648. }
  649. });
  650. }
  651. // #endif
  652. // #ifdef H5
  653. if(agent_code && token == ''){
  654. var env = {
  655. isIPad: /ipad/i.test(window.navigator.userAgent),
  656. isIphone: /iphone|ipad|ipod/i.test(window.navigator.userAgent),
  657. isWechat: /MicroMessenger/i.test(window.navigator.userAgent)
  658. }
  659. if(env.isWechat){
  660. if(e.openid){
  661. this.$cookieStorage.set('openid',e.openid)
  662. }
  663. var openid = this.$cookieStorage.get('openid') || e.openid;
  664. if(openid){
  665. this.postNewQuickLogin(openid,agent_code);
  666. } else{
  667. let origin = window.location.origin;
  668. var url = origin+'/pages/user/personal/personal?agent_code='+agent_code;
  669. window.location.href = this.$config.GLOBAL.baseUrl+'oauth/wxOauth?redirect_url='+encodeURIComponent(url);
  670. }
  671. } else{
  672. wx.navigateTo({
  673. url:'/pages/user/loginType/loginType'
  674. })
  675. }
  676. }
  677. // #endif
  678. } else {
  679. this.setCode(e);
  680. }
  681. } else {
  682. this.setCode(e);
  683. }
  684. });
  685. },
  686. postNewQuickLogin(open_id,agent_code){
  687. wx.showLoading({
  688. title: '正在登录',
  689. mask: true
  690. });
  691. this.$http.post({
  692. api:'api/oauth/newQuickLogin',
  693. data:{
  694. open_id:open_id,
  695. agent_code:agent_code
  696. }
  697. }).then(res=>{
  698. res = res.data;
  699. if(res.status){
  700. if(res.data.access_token){
  701. var access_token = res.data.token_type + ' ' + res.data.access_token;
  702. var expires_in = res.data.expires_in || 315360000;
  703. this.$cookieStorage.set("user_token", access_token, expires_in);
  704. //如果用户没有绑定手机号
  705. if(res.data.has_bind_mobile == 0){
  706. wx.reLaunch({
  707. url:'/pages/user/bindingphone/bindingphone'
  708. })
  709. } else{
  710. this.token = this.$cookieStorage.get('user_token');
  711. if(this.token){
  712. this.getUserInfo();
  713. this.getCenter();
  714. }
  715. }
  716. } else{
  717. wx.showModal({
  718. content: res.message || '请求失败,请重试',
  719. showCancel: false
  720. });
  721. }
  722. } else{
  723. wx.showModal({
  724. content: res.message || '请求失败,请重试',
  725. showCancel: false
  726. });
  727. }
  728. wx.hideLoading()
  729. }).catch(rej=>{
  730. wx.showModal({
  731. content: rej.message || '请求失败,请重试',
  732. showCancel: false
  733. });
  734. wx.hideLoading()
  735. })
  736. },
  737. setCode(e) {
  738. const timeMap = {
  739. y: 31536000000,
  740. m: 2592000000,
  741. d: 86400000,
  742. h: 3600000,
  743. n: 60000,
  744. s: 1000
  745. }; // 默认有效期为7天
  746. var valid_time = "";
  747. var clerk_id = e.clerk_id || "";
  748. var shop_id = e.shop_id || "";
  749. var agent_code = e.agent_code || '';
  750. if (e.scene) {
  751. var scene = decodeURIComponent(e.scene);
  752. var sceneArr = scene.split(',');
  753. if (sceneArr.length > 0) {
  754. agent_code = sceneArr[0];
  755. }
  756. }
  757. var cook_shop_id = this.$cookieStorage.get('shop_id');
  758. if (!this.$cookieStorage.get('distribution_valid_time')) {
  759. valid_time = 10080;
  760. } else {
  761. valid_time = this.$cookieStorage.get('distribution_valid_time');
  762. }
  763. let timeStamp = new Date().getTime();
  764. timeStamp += timeMap.n * valid_time; // 当url上shop_id与缓存中shop_id不一致时,需要清除clerk_id。以此保证shop_id与clerk_id对应
  765. var cook_clerk_id = this.$cookieStorage.get('clerk_id');
  766. if (cook_shop_id != shop_id && cook_clerk_id) {
  767. this.$cookieStorage.clear('clerk_id');
  768. }
  769. if (agent_code) {
  770. this.$cookieStorage.set('agent_code', agent_code, valid_time + 'n'); // 如果有agent_code就将这次进入的时间缓存
  771. this.$cookieStorage.set('agent_code_time', timeStamp, valid_time + 'n'); // 如果有agent_code并且有coupon_agent_code就将coupon_agent_code清除,保证agent_code为第一位
  772. if (this.$cookieStorage.get('coupon_agent_code')) {
  773. this.$cookieStorage.clear('coupon_agent_code');
  774. }
  775. }
  776. if (clerk_id) {
  777. this.$cookieStorage.set('clerk_id', clerk_id, valid_time + 'n');
  778. }
  779. if (shop_id) {
  780. this.$cookieStorage.set('shop_id', shop_id, valid_time + 'n'); // 如果有shop_id就将这次进入的时间缓存
  781. this.$cookieStorage.set('shop_id_time', timeStamp, valid_time + 'n');
  782. }
  783. },
  784. jumpAuthor() {
  785. wx.navigateTo({
  786. url: '/pages/index/author/author'
  787. });
  788. },
  789. getCode() {
  790. wx.login({
  791. success: res => {
  792. if (res.code) {
  793. this.code = res.code;
  794. }
  795. }
  796. });
  797. },
  798. jumpItem(e) {
  799. if (!this.token) {
  800. return this.jumpLogin();
  801. }
  802. var url = e.currentTarget.dataset.url;
  803. wx.navigateTo({
  804. url: url
  805. });
  806. },
  807. jumpLogin() {
  808. wx.navigateTo({
  809. url: '/pages/user/register/register'
  810. });
  811. },
  812. jumpPhone() {
  813. wx.navigateTo({
  814. url: '/pages/user/phone/phone'
  815. });
  816. },
  817. jumpFavor() {
  818. if (!this.token) {
  819. return this.jumpLogin();
  820. }
  821. wx.navigateTo({
  822. url: '/pages/favorite/index/index'
  823. });
  824. },
  825. jumpPoint() {
  826. if (!this.token) {
  827. return this.jumpLogin();
  828. }
  829. wx.navigateTo({
  830. url: '/pages/pointStore/index/index'
  831. });
  832. },
  833. jumpTravel() {
  834. if (!this.token) {
  835. return this.jumpLogin();
  836. }
  837. wx.navigateTo({
  838. url: '/pages/travels/myTravel/myTravel'
  839. });
  840. },
  841. getUserInfo() {
  842. this.$http.get({
  843. api: 'api/me',
  844. header: {
  845. Authorization: this.$cookieStorage.get('user_token')
  846. }
  847. }).then(res => {
  848. if (res.data.status) {
  849. if (!res.data.data.mobile || !res.data.data.user_info_fill) {
  850. this.top = 0;
  851. this.bottom = '5px';
  852. }
  853. this.detail = res.data.data;
  854. this.init = true;
  855. // 把头像和昵称存起来,签到页面直接获取
  856. this.$cookieStorage.set('userInfoImg', res.data.data.avatar)
  857. this.$cookieStorage.set('userInfoName', res.data.data.nick_name)
  858. if(!res.data.data.gift_is_receive){
  859. isBirthday().then(()=>{
  860. if(this.$cookieStorage.get("birthday_gift")){
  861. var giftData=this.$cookieStorage.get("birthday_gift").data;
  862. this.giftData = giftData;
  863. this.is_showBirth = true;
  864. }
  865. });
  866. }
  867. // #ifdef APP-PLUS
  868. if(res.data.data.user_info_fill == 0){
  869. var app_info = this.$cookieStorage.get('app_user_info');
  870. if(app_info){
  871. this.appUpdateInfo(app_info);
  872. }
  873. }
  874. // #endif
  875. }
  876. });
  877. },
  878. jumpAddress() {
  879. if (!this.token) {
  880. return this.jumpLogin();
  881. }
  882. wx.navigateTo({
  883. url: '/pages/address/list/list'
  884. });
  885. },
  886. jumpComment() {
  887. if (!this.token) {
  888. return this.jumpLogin();
  889. }
  890. wx.navigateTo({
  891. url: '/pages/order/comment/comment'
  892. });
  893. },
  894. jumpCollar() {
  895. if (!this.token) {
  896. return this.jumpLogin();
  897. }
  898. wx.navigateTo({
  899. url: '/pages/user/sign/sign'
  900. });
  901. },
  902. jumpBalance() {
  903. if (!this.token) {
  904. return this.jumpLogin();
  905. }
  906. wx.navigateTo({
  907. url: '/pages/recharge/balance/balance'
  908. });
  909. },
  910. jumpNews() {
  911. if (!this.token) {
  912. return this.jumpLogin();
  913. }
  914. wx.navigateTo({
  915. url: '/pages/user/news/news'
  916. });
  917. },
  918. jumpCan() {
  919. wx.navigateTo({
  920. url: '/pages/entity/index/index?shop_id=1'
  921. });
  922. },
  923. jumpDetail() {
  924. wx.navigateTo({
  925. url: '/pages/entity/detail/detail?id=1447&shop_id=1'
  926. });
  927. },
  928. jumpVip() {
  929. if (!this.token) {
  930. return this.jumpLogin();
  931. }
  932. var svip = this.initInfo.vip_plan_status;
  933. var isSvip = this.detail.vip;
  934. if (svip == 1) {
  935. if (isSvip) {
  936. wx.navigateTo({
  937. url: '/pages/user/svip/svip'
  938. });
  939. } else {
  940. wx.navigateTo({
  941. url: '/pages/recharge/index/index'
  942. });
  943. }
  944. } else {
  945. wx.navigateTo({
  946. url: '/pages/card/index/index'
  947. });
  948. }
  949. },
  950. jumpImg() {
  951. if (!this.token) {
  952. return this.jumpLogin();
  953. }
  954. wx.navigateTo({
  955. url: '/pages/user/setting/setting'
  956. });
  957. },
  958. jump(e) {
  959. if (!this.token) {
  960. return this.jumpLogin();
  961. }
  962. var status = e.currentTarget.dataset.status;
  963. wx.navigateTo({
  964. url: '/pages/order/index/index?type=' + status
  965. });
  966. },
  967. jumpAfterSales() {
  968. if (!this.token) {
  969. return this.jumpLogin();
  970. }
  971. wx.navigateTo({
  972. url: '/pages/afterSales/index/index'
  973. });
  974. },
  975. jumpSetting() {
  976. if (!this.token) {
  977. return this.jumpLogin();
  978. }
  979. wx.navigateTo({
  980. url: '/pages/user/out/out'
  981. });
  982. },
  983. bindUserInfo(e) {
  984. if (e.detail.encryptedData) {
  985. e.detail.code = this.code;
  986. this.updateUserInfo(e.detail);
  987. }
  988. },
  989. //app完善信息
  990. appUpdateInfo(data){
  991. wx.showLoading({
  992. title: '完善信息中',
  993. mask: true
  994. });
  995. this.$http.post({
  996. api:'api/users/update/info',
  997. data:{
  998. nick_name:data.nickName,
  999. avatar:data.avatarUrl
  1000. },
  1001. header: {
  1002. Authorization: this.$cookieStorage.get('user_token')
  1003. }
  1004. }).then(res=>{
  1005. res = res.data;
  1006. if(res.status){
  1007. this.getUserInfo()
  1008. } else{
  1009. wx.showModal({
  1010. content: res.message || '请求失败',
  1011. showCancel: false
  1012. });
  1013. }
  1014. wx.hideLoading();
  1015. }).catch(rej=>{
  1016. wx.showModal({
  1017. content: rej.message || '请求失败',
  1018. showCancel: false
  1019. });
  1020. wx.hideLoading();
  1021. })
  1022. },
  1023. updateUserInfo(data) {
  1024. wx.showLoading({
  1025. title: '完善信息中',
  1026. mask: true
  1027. });
  1028. this.$http.get({
  1029. api: 'api/user/bindUserMiniInfo',
  1030. data: data,
  1031. header: {
  1032. Authorization: this.$cookieStorage.get('user_token')
  1033. }
  1034. }).then(res => {
  1035. res = res.data;
  1036. if (res.status) {
  1037. // #ifdef MP-WEIXIN
  1038. this.getUserInfo();
  1039. // #endif
  1040. wx.hideLoading();
  1041. } else {
  1042. wx.showModal({
  1043. content: res.message || '请求失败',
  1044. showCancel: false
  1045. });
  1046. this.getCode();
  1047. wx.hideLoading();
  1048. }
  1049. wx.hideLoading();
  1050. }).catch(rej=>{
  1051. wx.showModal({
  1052. content: rej.message || '请求失败',
  1053. showCancel: false
  1054. });
  1055. wx.hideLoading();
  1056. });
  1057. },
  1058. //获取页面信息
  1059. getCenter() {
  1060. var token = this.$cookieStorage.get('user_token');
  1061. this.$http.get({
  1062. api: 'api/users/ucenter',
  1063. header: {
  1064. Authorization: token
  1065. }
  1066. }).then(res => {
  1067. if (res.data.status) {
  1068. this.newdetail = res.data.data;
  1069. }
  1070. });
  1071. },
  1072. // 获取广告图
  1073. getCenterList() {
  1074. this.$http.get({
  1075. api: 'api/user/center/img_list'
  1076. }).then(res => {
  1077. if (res.statusCode == 200) {
  1078. res = res.data;
  1079. if (res.status) {
  1080. this.img_list = res.data;
  1081. }
  1082. }
  1083. });
  1084. },
  1085. }
  1086. };
  1087. </script>
  1088. <style rel="stylesheet/less" lang="less">
  1089. @import "personal.less";
  1090. </style>