index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <template>
  2. <view class="user-area" v-if="fetch">
  3. <use-tabbar></use-tabbar>
  4. <view class="header-area padding-lr-sm" style="padding-top: 12px;">
  5. <view class="dflex-b">
  6. <view class="member-area padding-top-sm margin-bottom dflex pos-r flex1" v-if="login && fetch.user"
  7. @click="Dever.location('user/setting/info')">
  8. <view>
  9. <image class="headimg border-radius-c" :src="fetch.user.avatar" mode="aspectFill"></image>
  10. </view>
  11. <view class="margin-left-sm">
  12. <view class="info-box">
  13. <text class="fs-lg line-height-1">{{fetch.user.name}}</text>
  14. </view>
  15. <view>
  16. <text class="fs-xxs">{{fetch.user.mobile}}</text>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="member-area padding-top-sm margin-bottom dflex pos-r flex1" v-else>
  21. <view>
  22. <image class="headimg border-radius-c" :src="logo" mode="aspectFill"></image>
  23. </view>
  24. <view class="margin-left-sm" @click="goLogin">
  25. <view class="info-box">
  26. <text class="fs-lg">去登录</text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="border-radius-big bg-base dflex-c padding-lr margin-right"
  31. v-if="fetch.user && fetch.user.type == 2" @click="goBindMobile">
  32. <view class="iconfont fs-xl iconqiandao margin-right-xs"></view>
  33. <view>绑定手机号</view>
  34. </view>
  35. <view class="border-radius-big bg-base dflex-c padding-lr margin-right"
  36. v-if="fetch.user && fetch.user.type == 1 && Dever.env == 5" @click="goBindInfo">
  37. <view class="iconfont fs-xl iconqiandao margin-right-xs"></view>
  38. <view>修改资料</view>
  39. </view>
  40. <view class="border-radius-big bg-base dflex-c padding-lr margin-right"
  41. v-if="fetch.sales && fetch.sales.length > 0" @click="goSales">
  42. <view class="iconfont fs-xl iconqiandao margin-right-xs"></view>
  43. <view>店铺管理</view>
  44. </view>
  45. </view>
  46. <view class="border-radius">
  47. <view class="vip-card-area pos-r padding-lr-lg use-hover" v-if="fetch.role_info && fetch.role_info.button"
  48. @click="goRole(fetch.role_info)">
  49. <view class="dflex-b">
  50. <view class="dflex">
  51. <text class="iconfont iconhuiyuan ft-base line-height-1 margin-right-xs"></text>
  52. <view class="animated uscroll">
  53. <text class="margin-left-xs">{{fetch.role_info.subname}}</text>
  54. </view>
  55. </view>
  56. <view>
  57. <text class="fs-xs border-radius-lg padding-tb-xs padding-lr-sm"
  58. style="color: rgb(182, 91, 93); border: 1px solid rgb(182, 91, 93);">{{fetch.role_info.button}}</text>
  59. </view>
  60. </view>
  61. </view>
  62. <u-grid :border="false" class="stats-area dflex-c bg-main" v-if="login && fetch.user">
  63. <u-grid-item v-if="fetch.score && fetch.score.length > 0" v-for="(item, index) in fetch.score"
  64. :key="index">
  65. <view class="item dflex dflex-flow-c" @click="goScore(item)">
  66. <text class="num">{{item.num}}</text>
  67. <text>{{item.name}}</text>
  68. </view>
  69. <view class="vertical-line"></view>
  70. </u-grid-item>
  71. <u-grid-item>
  72. <view class="item dflex dflex-flow-c" @click="go('user/coupon/list')">
  73. <text class="num">{{fetch.user.coupon}}</text>
  74. <text>优惠券</text>
  75. </view>
  76. <view class="vertical-line"></view>
  77. </u-grid-item>
  78. <u-grid-item>
  79. <view class="item dflex dflex-flow-c" @click="go('user/gift/list')">
  80. <text class="num">{{fetch.user.gift}}</text>
  81. <text>礼品卡</text>
  82. </view>
  83. <view class="vertical-line"></view>
  84. </u-grid-item>
  85. <u-grid-item>
  86. <view class="item dflex dflex-flow-c" @click="go('user/perk/list')">
  87. <text class="num">{{fetch.user.perk}}</text>
  88. <text>权益包</text>
  89. </view>
  90. <view class="vertical-line"></view>
  91. </u-grid-item>
  92. </u-grid>
  93. <!--
  94. <u-grid :border="false" class="stats-area dflex-c bg-main" v-if="login && fetch.user">
  95. <u-grid-item>
  96. <view class="item dflex dflex-flow-c" @click="go('user/coupon/list')">
  97. <text class="num">{{fetch.user.coupon}}</text>
  98. <text>优惠券</text>
  99. </view>
  100. <view class="vertical-line"></view>
  101. </u-grid-item>
  102. <u-grid-item>
  103. <view class="item dflex dflex-flow-c" @click="go('user/gift/list')">
  104. <text class="num">{{fetch.user.gift}}</text>
  105. <text>礼品卡</text>
  106. </view>
  107. <view class="vertical-line"></view>
  108. </u-grid-item>
  109. <u-grid-item>
  110. <view class="item dflex dflex-flow-c" @click="go('user/perk/list')">
  111. <text class="num">{{fetch.user.perk}}</text>
  112. <text>权益包</text>
  113. </view>
  114. <view class="vertical-line"></view>
  115. </u-grid-item>
  116. </u-grid>
  117. -->
  118. </view>
  119. </view>
  120. <view class="container-area padding-lr-sm padding-bottom-sm">
  121. <view class="border-radius margin-top-sm bg-main">
  122. <view class="use-list-title dflex-b padding-lr w-full bg-main" @click="go('order/list')">
  123. <view class="dflex">
  124. <view class="iconfont __left margin-right-sm icondingdan" style="color: rgb(255, 106, 108);">
  125. </view>
  126. <text class="flex1 ws-np" style="font-size: 13px; font-weight: 600;">我的订单</text>
  127. </view>
  128. <view class="dflex margin-left-xl">
  129. <text class="tip line-height-1 margin-right-xs">查看全部订单</text>
  130. <view class="iconfont fs-sm iconjiantou-01" style="color: rgb(192, 192, 192);"></view>
  131. </view>
  132. </view>
  133. <view class="order-area padding-bottom-sm padding-lr dflex-c">
  134. <view class="item dflex dflex-flow-c" @click="go('order/list?status=1')">
  135. <view class="iconfont"><view class="badge badge-small" v-if="fetch.order_1 > 0">
  136. {{fetch.order_1}}
  137. </view>
  138. </view>
  139. <text>待付款</text>
  140. </view>
  141. <view class="item dflex dflex-flow-c" @click="go('order/list?status=2')">
  142. <view class="iconfont"><view class="badge badge-small" v-if="fetch.order_2 > 0">
  143. {{fetch.order_2}}
  144. </view>
  145. </view>
  146. <text>待发货</text>
  147. </view>
  148. <view class="item dflex dflex-flow-c" @click="go('order/list?status=3')">
  149. <view class="iconfont"><view class="badge badge-small" v-if="fetch.order_3 > 0">
  150. {{fetch.order_3}}
  151. </view>
  152. </view>
  153. <text>待收货</text>
  154. </view>
  155. <view class="item dflex dflex-flow-c" @click="go('order/list?status=4')">
  156. <view class="iconfont"><view class="badge badge-small" v-if="fetch.order_4 > 0">
  157. {{fetch.order_4}}
  158. </view>
  159. </view>
  160. <text>待评价</text>
  161. </view>
  162. </view>
  163. </view>
  164. <view class="border-radius margin-top-sm bg-main">
  165. <view class="use-list-title dflex-b padding-lr w-full bg-main" @click="open('role')"
  166. v-if="fetch.role && fetch.role.length > 0">
  167. <view class="dflex">
  168. <view class="iconfont __left margin-right-sm icongerenzhongxin-1"
  169. style="color: rgb(85, 170, 255);">
  170. </view>
  171. <text class="flex1 ws-np" style="font-size: 13px; font-weight: 600;">我的身份</text>
  172. </view>
  173. <view class="dflex margin-left-xl">
  174. <text class="tip line-height-1 margin-right-xs">
  175. 升级身份,立享权益
  176. </text>
  177. </view>
  178. <!--
  179. <view class="dflex margin-left-xl">
  180. <text class="tip line-height-1 margin-right-xs" v-if="fetch.role && fetch.role.length > 0" v-for="(v, k) in fetch.role" :key="k">
  181. {{v.name}}
  182. </text>
  183. <view class="iconfont fs-sm iconjiantou-01" style="color: rgb(192, 192, 192);"></view>
  184. </view>-->
  185. </view>
  186. <view class="header-area padding-lr-sm">
  187. <view class="border-radius">
  188. <u-grid :border="false" class="stats-area dflex-c bg-main" v-if="login && fetch.user">
  189. <u-grid-item v-if="fetch.role && fetch.role.length > 0" v-for="(v, k) in fetch.role"
  190. :key="k" @click="go('role/info?id=' + v.id)">
  191. <view class="item dflex dflex-flow-c">
  192. <text class="num">{{v.name}}</text>
  193. <text>{{v.subname}}</text>
  194. </view>
  195. <view class="vertical-line"></view>
  196. </u-grid-item>
  197. </u-grid>
  198. </view>
  199. </view>
  200. <!--
  201. <u-action-sheet v-if="fetch && fetch.role && fetch.role.length > 0" :actions="fetch.role" :closeOnClickAction="true" :closeOnClickOverlay="true" :show="show.role" @select="goRole" @close="close('role')" :round="14" title="我的身份"></u-action-sheet>-->
  202. <view class="use-list-title dflex-b padding-lr w-full bg-main">
  203. <view class="dflex">
  204. <view class="iconfont __left margin-right-sm iconhaibao1" style="color: rgb(85, 170, 255);">
  205. </view>
  206. <text class="flex1 ws-np" style="font-size: 13px; font-weight: 600;">我的团队</text>
  207. </view>
  208. <view class="dflex margin-left-xl">
  209. <text class="tip line-height-1 margin-right-xs">
  210. 建立团队,分享赚钱
  211. </text>
  212. </view>
  213. </view>
  214. <view class="header-area padding-lr-sm">
  215. <view class="border-radius">
  216. <u-grid :border="false" class="stats-area dflex-c bg-main" v-if="login && fetch.user">
  217. <u-grid-item @click="openPoster">
  218. <view class="item dflex dflex-flow-c">
  219. <text class="num">邀请</text>
  220. <text>团队拉新</text>
  221. </view>
  222. <view class="vertical-line"></view>
  223. </u-grid-item>
  224. <u-grid-item @click="go('group/member')">
  225. <view class="item dflex dflex-flow-c">
  226. <text class="num">成员</text>
  227. <text>团队成员</text>
  228. </view>
  229. <view class="vertical-line"></view>
  230. </u-grid-item>
  231. <u-grid-item @click="go('group/order')">
  232. <view class="item dflex dflex-flow-c">
  233. <text class="num">账单</text>
  234. <text>团队账单</text>
  235. </view>
  236. <view class="vertical-line"></view>
  237. </u-grid-item>
  238. </u-grid>
  239. </view>
  240. </view>
  241. <view class="use-list-title dflex-b padding-lr w-full bg-main" @click="go('user/benefit/list')">
  242. <view class="dflex">
  243. <view class="iconfont __left margin-right-sm iconaixin-01" style="color: #6a92ff;">
  244. </view>
  245. <text class="flex1 ws-np" style="font-size: 13px; font-weight: 600;">我的权益</text>
  246. </view>
  247. <view class="dflex margin-left-xl">
  248. <text class="tip line-height-1 margin-right-xs"></text>
  249. <view class="iconfont fs-sm iconjiantou-01" style="color: rgb(192, 192, 192);"></view>
  250. </view>
  251. </view>
  252. </view>
  253. <view class="border-radius margin-top-sm bg-main">
  254. <view class="use-list-title dflex-b padding-lr w-full bg-main" @click="go('user/act/collect')">
  255. <view class="dflex">
  256. <view class="iconfont __left margin-right-sm iconshoucang-" style="color: rgb(255, 106, 108);">
  257. </view>
  258. <text class="flex1 ws-np" style="font-size: 13px; font-weight: 600;">我的收藏</text>
  259. </view>
  260. <view class="dflex margin-left-xl">
  261. <text class="tip line-height-1 margin-right-xs"></text>
  262. <view class="iconfont fs-sm iconjiantou-01" style="color: rgb(192, 192, 192);"></view>
  263. </view>
  264. </view>
  265. <scroll-view scroll-x class="browsing-area padding-lr">
  266. <view class="dflex">
  267. <view v-for="(item, index) in fetch.list" :key="index">
  268. <image class="border-radius-sm margin-right-sm" :src="item.cover" mode="aspectFill"
  269. @click="Dever.location('source/info?id=' + item.id + '&title=' + item.name)"></image>
  270. </view>
  271. </view>
  272. </scroll-view>
  273. <view class="use-list-title dflex-b padding-lr w-full bg-main" @click="go('user/address/list')">
  274. <view class="dflex">
  275. <view class="iconfont __left margin-right-sm icondizhi-" style="color: rgb(170, 170, 255);">
  276. </view>
  277. <text class="flex1 ws-np" style="font-size: 13px; font-weight: 600;">收件人</text>
  278. </view>
  279. <view class="dflex margin-left-xl">
  280. <text class="tip line-height-1 margin-right-xs"></text>
  281. <view class="iconfont fs-sm iconjiantou-01" style="color: rgb(192, 192, 192);"></view>
  282. </view>
  283. </view>
  284. <view class="use-list-title dflex-b padding-lr w-full bg-main" @click="go('user/setting/setting')">
  285. <view class="dflex">
  286. <view class="iconfont __left margin-right-sm iconshezhi-" style="color: rgb(88, 188, 138);">
  287. </view>
  288. <text class="flex1 ws-np" style="font-size: 13px; font-weight: 600;">设置</text>
  289. </view>
  290. <view class="dflex margin-left-xl">
  291. <text class="tip line-height-1 margin-right-xs"></text>
  292. <view class="iconfont fs-sm iconjiantou-01" style="color: rgb(192, 192, 192);"></view>
  293. </view>
  294. </view>
  295. </view>
  296. <view class="border-radius margin-top-sm padding-sm dflex-c bg-main log-out-btn" v-if="login"
  297. @click="goLogin">
  298. <view class="cell-tit">切换账号</view>
  299. </view>
  300. <view class="border-radius margin-top-sm padding-sm dflex-c bg-main log-out-btn" v-else @click="goLogin">
  301. <view class="cell-tit">去登录</view>
  302. </view>
  303. </view>
  304. <use-copyright :title="title" :desc="info"></use-copyright>
  305. <u-action-sheet v-if="fetch.user" :closeOnClickOverlay="true" @error="getMobileError"
  306. @getphonenumber="getMobile" :closeOnClickAction="false" @close="closeBindMobile" @select="selectMobile"
  307. :actions="bindMobile.list" :title="bindMobile.title" :show="bindMobile.show"></u-action-sheet>
  308. <u-wx-auth v-if="fetch.user" ref="wxAuthRef" :show="bindInfo.show" :logo="logo" :title="title"
  309. :tips="bindInfo.tips" :confirm-text="bindInfo.confirmText" @choose-avatar="onChooseAvatar"
  310. @confirm="onConfirm" @close="closeBindInfo"></u-wx-auth>
  311. <u-action-sheet v-if="fetch.sales && fetch.sales.length > 0" :closeOnClickOverlay="true" :height="300"
  312. :closeOnClickAction="false" @close="closeSales" @select="selectSales" :actions="fetch.sales"
  313. titleStyle="color:#bababa" :title="sales.title" :show="sales.show"></u-action-sheet>
  314. <use-poster ref="poster" @setShare="setShare"></use-poster>
  315. </view>
  316. </template>
  317. <script>
  318. export default {
  319. data() {
  320. return {
  321. fetch: {},
  322. login: false,
  323. logo: '',
  324. title: '',
  325. info: '',
  326. // 弹窗展示
  327. show: {
  328. role: false,
  329. },
  330. // 销售渠道
  331. sales: {
  332. show: false,
  333. title: '点击店铺名称进入管理',
  334. },
  335. // 绑定资料
  336. bindInfo: {
  337. show: false,
  338. tips: '以便为您提供更优质的服务',
  339. },
  340. // 绑定手机号
  341. bindMobile: {
  342. show: false,
  343. title: '请选择绑定方式',
  344. list: [{
  345. id: 1,
  346. name: '微信授权',
  347. subname: "授权手机号,一键快速绑定",
  348. color: '#ffaa7f',
  349. fontSize: '20',
  350. openType: 'getPhoneNumber',
  351. //openType: 'getUserInfo',
  352. },
  353. {
  354. id: 2,
  355. name: '验证码绑定',
  356. subname: "接收验证码,手动绑定",
  357. },
  358. ],
  359. },
  360. share: {
  361. name: '',
  362. path: '',
  363. pic: '',
  364. }
  365. }
  366. },
  367. onLoad() {
  368. //#ifdef MP-WEIXIN
  369. wx.hideShareMenu({
  370. menus: ['shareAppMessage', 'shareTimeline']
  371. })
  372. //#endif
  373. },
  374. onShow() {
  375. this.load();
  376. this.loadData();
  377. this.loadCollect();
  378. },
  379. // 小程序分享
  380. onShareAppMessage(res) {
  381. if (res.from === 'button' && this.share && this.share.name && this.share.path) {
  382. return {
  383. title: this.share.name,
  384. path: this.share.path,
  385. imageUrl: this.share.pic || '',
  386. }
  387. }
  388. return null
  389. },
  390. methods: {
  391. setShare(value) {
  392. this.share = value;
  393. },
  394. load() {
  395. this.login = false;
  396. if (this.DeverApi.getToken()) {
  397. this.login = true;
  398. }
  399. this.Dever.config().then(config => {
  400. this.logo = config.l;
  401. this.title = config.n;
  402. this.info = config.i;
  403. });
  404. },
  405. loadData() {
  406. if (this.login) {
  407. this.DeverApi.get(this, 'user.info', {}, res => {
  408. this.login = true;
  409. });
  410. } else {
  411. this.DeverApi.get(this, 'main.getUserHome');
  412. }
  413. },
  414. loadCollect() {
  415. this.DeverApi.page([1, 'list'], this, 'collect.getUserList');
  416. },
  417. quit() {
  418. this.Dever.confirm('确认退出登录吗?', () => {
  419. this.DeverApi.setToken('');
  420. this.login = false;
  421. })
  422. },
  423. go(url) {
  424. if (this.login) {
  425. this.Dever.location(url)
  426. } else {
  427. this.Dever.confirm('您需要登录才能继续操作', () => {
  428. this.Dever.goLogin(url);
  429. })
  430. }
  431. },
  432. goLogin() {
  433. this.Dever.goLogin();
  434. },
  435. goRole(e) {
  436. this.go('role/info?id=' + e.id);
  437. },
  438. goScore(e) {
  439. this.go('score/info?id=' + e.id);
  440. },
  441. open(key) {
  442. this.show[key] = true;
  443. },
  444. close(key) {
  445. this.show[key] = false;
  446. },
  447. goSales() {
  448. this.sales.show = true;
  449. },
  450. closeSales() {
  451. this.sales.show = false;
  452. },
  453. selectSales(e) {
  454. this.Dever.location('sales/home?type=' + e.sales_type + '&id=' + e.id);
  455. },
  456. goBindMobile() {
  457. if (this.Dever.env === 5 && this.Dever.platform == 'weixin') {
  458. //打开授权
  459. this.bindMobile.show = true;
  460. } else {
  461. this.Dever.location('user/bind/mobile')
  462. }
  463. },
  464. selectMobile(e) {
  465. if (e.id == 1) {
  466. } else {
  467. this.Dever.location('user/bind/mobile')
  468. }
  469. },
  470. closeBindMobile() {
  471. this.bindMobile.show = false;
  472. },
  473. getMobile(e) {
  474. if (e.detail.errMsg !== "getPhoneNumber:ok") {
  475. uni.showToast({
  476. title: "用户拒绝授权",
  477. icon: "none"
  478. });
  479. return;
  480. }
  481. const code = e.detail.code;
  482. this.DeverApi.post('bind.getWexinMobile', {
  483. code: code
  484. }, res => {
  485. this.Dever.alert('绑定成功', 'success', () => {
  486. this.loadData()
  487. });
  488. });
  489. },
  490. getMobileError() {
  491. this.Dever.alert('授权失败,请重试');
  492. },
  493. goBindInfo() {
  494. this.bindInfo.show = true;
  495. },
  496. closeBindInfo() {
  497. this.bindInfo.show = false;
  498. },
  499. onChooseAvatar(url) {
  500. this.DeverApi.post('user.upload', {
  501. file: url
  502. }, res => {
  503. this.$refs.wxAuthRef.avatar = res.url;
  504. });
  505. },
  506. onConfirm(data) {
  507. // data.avatar - 用户头像路径,如果不调用onChooseAvatar中的方法1或者方法2,则avatar是临时文件的路径
  508. // data.nickname - 用户昵称
  509. this.DeverApi.post('user.update', {
  510. avatar: data.avatar,
  511. name: data.nickname
  512. }, res => {
  513. this.loadData()
  514. });
  515. this.closeBindInfo();
  516. },
  517. openPoster() {
  518. this.$refs.poster.open(this.fetch.user.name, this.title, this.info, this.logo, this.fetch.user.avatar, '', {})
  519. }
  520. }
  521. }
  522. </script>
  523. <style lang="scss">
  524. .member-area {
  525. image {
  526. width: 124rpx;
  527. height: 124rpx;
  528. border: 4rpx solid #fff;
  529. }
  530. }
  531. .vip-card-area {
  532. padding-top: 10rpx;
  533. padding-bottom: 10rpx;
  534. font-size: 22rpx;
  535. color: #c6b181;
  536. background-color: #000;
  537. background-image: linear-gradient(90deg, #3a3a3a, #000);
  538. .iconfont {
  539. font-size: 62rpx;
  540. }
  541. }
  542. .border-radius {
  543. border-radius: 18rpx;
  544. }
  545. .item {
  546. padding: 28rpx 0;
  547. position: relative;
  548. font-size: 22rpx;
  549. color: #75787d;
  550. flex: 1;
  551. }
  552. .num {
  553. font-size: 30rpx;
  554. color: #303133;
  555. margin-bottom: 4rpx;
  556. }
  557. .order-area {
  558. .item {
  559. position: relative;
  560. font-size: 22rpx;
  561. color: #75787d;
  562. flex: 1;
  563. }
  564. .num {
  565. font-size: 30rpx;
  566. color: #303133;
  567. margin-bottom: 4rpx;
  568. }
  569. }
  570. .browsing-area {
  571. image {
  572. width: 152rpx;
  573. height: 152rpx;
  574. }
  575. }
  576. .log-out-btn {
  577. color: #75787d;
  578. }
  579. .badge {
  580. margin-right: 20rpx;
  581. }
  582. </style>