user.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <view class="user-area">
  3. <view style="width: 100%;height: 320px;">
  4. <view class="header-area padding-lr-sm" :class="(is_mp && !is_alipay) ? 'padding-top-big' : 'padding-top'">
  5. <view>
  6. <view class="member-area padding-top-use pos-r">
  7. <!-- @click="to('/packageShang/pages/user/setting/personal')" -->
  8. <view>
  9. <image class="headimg border-radius-c" :src="list.avatarUrl || '/static/images/user/default.png'"></image>
  10. </view>
  11. <view class="margin-left-user">
  12. <view class="info-box">
  13. <text class="fs-lg">{{ list.nickName || '大魏' }}</text>
  14. </view>
  15. <view v-if="member.member_city"><text class="fs-xxs">{{ member.member_city }}</text></view>
  16. </view>
  17. </view>
  18. <!-- <view class="border-radius-big bg-base dflex-c padding-lr"
  19. style="z-index: 99;position: fixed;"
  20. @click="to('/packageShang/pages/user/integral/sign')">
  21. <view class="iconfont fs-xl iconqiandao margin-right-xs"></view>
  22. <view>签到</view>
  23. </view> -->
  24. </view>
  25. <view class="border-radius">
  26. <view class="stats-area dflex-c">
  27. <view class="item dflex dflex-flow-c" @click="toOrder('/packageShang/pages/user/order/order', '全部')">
  28. <text class="num">{{ member.member_monetary / 100 || 0 }}</text>
  29. <text>我的余额</text>
  30. </view>
  31. <view class="item dflex dflex-flow-c" @click="toOrder('/packageShang/pages/user/order/order', '全部')">
  32. <text class="num">{{ pointsAmount || 0 }}</text>
  33. <text>我的积分</text>
  34. </view>
  35. <!-- <view class="item dflex dflex-flow-c" @click="to('/packageShang/pages/user/coupon/coupon')">
  36. <text class="num">{{ member.member_coupon_cnt || 6 }}</text>
  37. <text>优惠券</text>
  38. </view> -->
  39. </view>
  40. <view class="vip-card-area pos-r padding-lr padding-tb-sm">
  41. <!-- <view style="margin: 28rpx 0 0 4rpx;width: 100%;height: 100%;">
  42. <image class="vip" src="../../static/images/user/VIP.png"></image>
  43. <text class="margin-left-sm" style="line-height: 42rpx;">会员立享5大权益</text>
  44. <view class="margin-left-kai">立即开通</view>
  45. </view> -->
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="container-area padding-lr-sm padding-bottom-sm">
  51. <!-- 我的订单 -->
  52. <view class="border-radius margin-top-sm bg-main">
  53. <use-list-title title="我的订单" iconfont="none" fwt="600" tip="查看全部订单"
  54. @goto="toOrder('/packageShang/pages/user/order/order', '全部')"></use-list-title>
  55. <view class="order-area padding-bottom-sm padding-lr dflex-c">
  56. <view class="item dflex dflex-flow-c" @click="toOrder('/packageShang/pages/user/order/order', '待付款')">
  57. <view class="iconfont">&#xe6da;<view class="badge badge-small"
  58. v-if="stats && stats.order_state && stats.order_state['待付款'] > 0">
  59. {{stats.order_state['待付款']}}
  60. </view>
  61. </view>
  62. <text>待付款</text>
  63. </view>
  64. <view class="item dflex dflex-flow-c" @click="toOrder('/packageShang/pages/user/order/order', '待发货')">
  65. <view class="iconfont">&#xe6d9;<view class="badge badge-small"
  66. v-if="stats && stats.order_state && stats.order_state['待发货'] > 0">
  67. {{stats.order_state['待发货']}}
  68. </view>
  69. </view>
  70. <text>待发货</text>
  71. </view>
  72. <view class="item dflex dflex-flow-c" @click="toOrder('/packageShang/pages/user/order/order', '待收货')">
  73. <view class="iconfont">&#xe6d7;<view class="badge badge-small"
  74. v-if="stats && stats.order_state && stats.order_state['待收货'] > 0">
  75. {{stats.order_state['待收货']}}
  76. </view>
  77. </view>
  78. <text>待收货</text>
  79. </view>
  80. <view class="item dflex dflex-flow-c" @click="toOrder('/packageShang/pages/user/order/order', '待评价')">
  81. <view class="iconfont">&#xe6db;<view class="badge badge-small"
  82. v-if="stats && stats.order_state && stats.order_state['待评价'] > 0">
  83. {{stats.order_state['待评价']}}
  84. </view>
  85. </view>
  86. <text>待评价</text>
  87. </view>
  88. <view class="item dflex dflex-flow-c" @click="toOrder('/packageShang/pages/user/order/order', '已完成')">
  89. <view class="iconfont">&#xe6db;<view class="badge badge-small"
  90. v-if="stats && stats.order_state && stats.order_state['已完成'] > 0">
  91. {{stats.order_state['已完成']}}
  92. </view>
  93. </view>
  94. <text>已完成</text>
  95. </view>
  96. <!-- <view class="item dflex dflex-flow-c" @click="toOrder('/packageShang/pages/user/order/order', '退款')">
  97. <view class="iconfont">&#xe715;<view class="badge badge-small"
  98. v-if="stats && stats.order_state && stats.order_state['退款'] > 0">
  99. {{stats.order_state['退款']}}
  100. </view>
  101. </view>
  102. <text>售后/退款</text>
  103. </view> -->
  104. </view>
  105. </view>
  106. <view class="border-radius margin-top-sm bg-main">
  107. <!-- 我的足迹 -->
  108. <use-list-title title="我的足迹" iconfont="iconzuji" color="rgba(36, 147, 241, 1)" fwt="600" :tip="stats.browsing"
  109. @goto="to('/packageShang/pages/user/browsing/browsing')"></use-list-title>
  110. <scroll-view scroll-x class="browsing-area padding-lr">
  111. <view class="dflex">
  112. <view v-for="(item, index) in historyDatas" :key="index">
  113. <image class="border-radius-sm margin-right-sm" @click="togoods(item)" :src="item.goodsMainImageUrl"
  114. mode="aspectFill"></image>
  115. </view>
  116. </view>
  117. </scroll-view>
  118. <use-list-title title="我的收藏" iconfont="iconshoucang-" color="#ff6a6c" fwt="600" :tip="stats.collect"
  119. @goto="to('/packageShang/pages/user/collect/collect')"></use-list-title>
  120. <!-- <use-list-title title="分销中心" iconfont="iconyixiaoshou" color="#ffab6c" fwt="600" tip="分享赚钱"
  121. @goto="to('/packageShang/pages/user/distribution/distribution')"></use-list-title> -->
  122. <use-list-title title="收货人" iconfont="icondizhi-" color="#5a9ded" fwt="600"
  123. @goto="to('/packageShang/pages/user/address/address')"></use-list-title>
  124. <!-- <use-list-title title="设置" iconfont="iconshezhi-" color="#58bc8a" fwt="600"
  125. @goto="to('/packageShang/pages/user/setting/setting')"></use-list-title> -->
  126. </view>
  127. <view v-if="list.avatarUrl" class="border-radius margin-top-sm padding-sm dflex-c bg-main log-out-btn"
  128. @click="openActionSheet">
  129. <text class="cell-tit">退出登录</text>
  130. </view>
  131. <!-- <view v-else class="border-radius margin-top-sm padding-sm dflex-c bg-main log-out-btn"
  132. @click="to('/pages/login/login')">
  133. <text class="cell-tit">去登录</text>
  134. </view> -->
  135. <view style="width: 100%;height: 70px;"></view>
  136. <!-- 操作菜单 -->
  137. <!-- <use-action-sheet v-model="actionSheetShow" :list="actionSheetList" :tips="actionSheetTips"
  138. @click="actionSheetClick" @close="actionSheetClose"></use-action-sheet> -->
  139. </view>
  140. <tabbar :current-page="3"></tabbar>
  141. </view>
  142. </template>
  143. <script>
  144. import {
  145. orserlist,
  146. footlist
  147. } from '../../utils/api_user.js'
  148. import tabbar from '../tabbar.vue'
  149. import common from '../../../static/comon.js'
  150. import useListTitle from '../../components/use-list-title/use-list-title.vue'
  151. import useActionSheet from '../../components/use-action-sheet/use-action-sheet.vue'
  152. const db = uniCloud.database();
  153. const _history = 'usemall-goods-history'
  154. export default {
  155. components:{
  156. useListTitle,
  157. useActionSheet,
  158. tabbar
  159. },
  160. data() {
  161. return {
  162. list: {},
  163. pointsAmount: '',//积分
  164. isreq: false,
  165. // 浏览历史
  166. historyDatas: [],
  167. // 统计数据
  168. stats: {},
  169. actionSheetShow: false,
  170. actionSheetList: [],
  171. actionSheetTips: {
  172. text: "",
  173. color: "#9a9a9a",
  174. size: 24
  175. },
  176. is_mp: false,
  177. is_alipay: false,
  178. };
  179. },
  180. onLoad() {
  181. var token = uni.getStorageSync('tokenId');
  182. this.isReal(token)
  183. var _self = this
  184. if(token){
  185. this.getIndex()
  186. uni.getUserInfo({
  187. provider: 'weixin',
  188. success: function (infoRes) {
  189. _self.list = infoRes.userInfo
  190. }
  191. })
  192. }else{
  193. _self.list = {}
  194. }
  195. _self.$nextTick(() => {
  196. _self.is_mp = _self.$env.is_mp;
  197. _self.is_alipay = _self.$env.platform == 'alipay';
  198. })
  199. },
  200. onShow() {
  201. this.loadData();
  202. },
  203. methods: {
  204. // 获取积分
  205. getIndex(){
  206. var token = uni.getStorageSync('tokenId');
  207. var _self = this;
  208. uni.request({
  209. url: common.url + 'integral/user/integralIndex',
  210. header: {"User-Token": token},
  211. success(res) {
  212. res = res.data
  213. if(res.status == 'success'){
  214. _self.pointsAmount = res.data.pointsAmount
  215. }else{
  216. if (res.data.errCode == '10006'){
  217. common.isOverdue()
  218. }
  219. }
  220. }
  221. })
  222. },
  223. // 获取用户实名信息进行判断是否已实名
  224. isReal(token) {
  225. var _self = this;
  226. uni.request({
  227. url: common.url + 'user/getUserRealName',
  228. header: {
  229. 'User-Token': token
  230. },
  231. success(res){
  232. res = res.data
  233. if (res.status == 'success'){
  234. // _self.text = '已认证'
  235. _self.isRight(token)
  236. }else if(res.status == 'fail') {
  237. // _self.text = '未认证'
  238. }
  239. }
  240. })
  241. },
  242. // 判断有无绑定房产
  243. isRight(token) {
  244. var _self = this;
  245. uni.request({
  246. url: common.url + 'user/getUserIsBindHouse',
  247. header:{
  248. "User-Token": token
  249. },
  250. success(res) {
  251. res = res.data
  252. if(res.status == 'success') {
  253. _self.haveHouseInfo = res.data.haveHouseInfo
  254. } else {
  255. if (res.data.errCode == '10006'){
  256. common.isOverdue()
  257. }
  258. }
  259. }
  260. })
  261. },
  262. // 加载数据
  263. loadData() {
  264. var _self = this;
  265. // 订单列表
  266. var header={
  267. "Mall-Token": uni.getStorageSync('tokenId')
  268. }
  269. orserlist(header).then((res) => {
  270. if (res.success) {
  271. this.stats = res.data;
  272. }
  273. })
  274. // 浏览历史足迹
  275. footlist().then((res) => {
  276. if (res.success) {
  277. res.data.list.forEach(x => {
  278. this.historyDatas.push(x);
  279. });
  280. }
  281. })
  282. },
  283. // 打开操作菜单
  284. openActionSheet() {
  285. try {
  286. uni.removeStorageSync('tokenId');
  287. uni.removeStorageSync('houseInfo');
  288. uni.removeStorageSync('address');
  289. uni.removeStorageSync('latitude');
  290. uni.removeStorageSync('longitude');
  291. uni.removeStorageSync('communityName');
  292. uni.removeStorageSync('communityId');
  293. uni.removeStorageSync('streetOfficeId');
  294. uni.removeStorageSync('streetOfficeName');
  295. uni.removeStorageSync('centerId');
  296. uni.navigateTo({
  297. url: '/pages/login/login'
  298. })
  299. } catch (e) {
  300. // error
  301. }
  302. },
  303. // 关闭操作菜单
  304. actionSheetClose() {
  305. console.log(this.actionSheetShow);
  306. },
  307. // 点击操作菜单
  308. actionSheetClick(index) {
  309. switch (index) {
  310. case 0:
  311. this.$api.msg('退出成功');
  312. this.logout();
  313. this.$api.timerout(() => {
  314. this.$api.tohome();
  315. }, 200);
  316. break;
  317. case 1:
  318. this.$api.tologin();
  319. break;
  320. }
  321. },
  322. // 统一跳转接口,拦截未登录路由
  323. to(url) {
  324. // if (!this.list.avatarUrl) {
  325. // this.$api.tologin()
  326. // return;
  327. // }
  328. console.log(url,'0')
  329. uni.navigateTo({
  330. url
  331. });
  332. },
  333. // 跳转到 订单
  334. toOrder(url, state) {
  335. // if (!this.list.avatarUrl) {
  336. // this.$api.tologin()
  337. // return;
  338. // }
  339. uni.setStorage({
  340. key: '__order_state',
  341. data: state,
  342. success(res) {
  343. console.log(res);
  344. },
  345. complete() {
  346. uni.navigateTo({
  347. url
  348. });
  349. }
  350. });
  351. },
  352. // 跳转商品详情
  353. togoods(item) {
  354. this.$api.togoods({
  355. id: item.goodsId
  356. });
  357. }
  358. }
  359. };
  360. </script>
  361. <style lang="scss">
  362. @import url('/packageShang/components/iconfont/iconfont.css');
  363. @import url('/packageShang/common/common.scss');
  364. page {
  365. min-height: 100%;
  366. background: $page-color-base;
  367. }
  368. .header-area{
  369. padding: 0px;
  370. width: 750rpx;
  371. height: 560rpx;
  372. background-image: url('../../static/images/user/user-bg.png');
  373. background-size: 100%;
  374. }
  375. .member-area {
  376. image {
  377. width: 130rpx;
  378. height: 130rpx;
  379. border: 5rpx solid #fff;
  380. }
  381. }
  382. .vip-card-area {
  383. margin-left: 30rpx;
  384. width: 690rpx;
  385. height: 136rpx;
  386. opacity: 1;
  387. border-radius: 20rpx;
  388. background: rgba(35, 39, 52, 1);
  389. font-size: 32rpx;
  390. color: rgba(255, 225, 192, 1);
  391. .vip{
  392. width: 98rpx;
  393. height: 42rpx;
  394. line-height: 50rpx;
  395. }
  396. .margin-left-kai{
  397. float: right;
  398. width: 136rpx;
  399. height: 56rpx;
  400. opacity: 1;
  401. border-radius: 28rpx;
  402. background: linear-gradient(270deg, rgba(226, 162, 92, 1) 0%, rgba(247, 229, 195, 1) 100%);
  403. font-size: 26rpx;
  404. line-height: 56rpx;
  405. color: rgba(35, 39, 52, 1);
  406. text-align: center;
  407. }
  408. }
  409. .stats-area {
  410. .item {
  411. padding: 30rpx 0;
  412. color: rgba(255, 255, 255, 1);
  413. position: relative;
  414. font-size: $font-sm;
  415. flex: 1;
  416. }
  417. .num {
  418. font-size: 40rpx;
  419. color: $font-color-dark;
  420. margin-bottom: 6rpx;
  421. }
  422. }
  423. .order-area {
  424. .item {}
  425. .iconfont {
  426. position: relative;
  427. font-size: $font-lg + 8upx;
  428. .badge {
  429. right: initial;
  430. }
  431. }
  432. }
  433. .order-area .item {
  434. position: relative;
  435. font-size: $font-sm;
  436. color: $font-color-base;
  437. flex: 1;
  438. }
  439. .browsing-area {
  440. image {
  441. width: 160rpx;
  442. height: 160rpx;
  443. }
  444. }
  445. ::-webkit-scrollbar {
  446. width: 0;
  447. height: 0;
  448. color: transparent;
  449. display: none;
  450. }
  451. .log-out-btn {
  452. color: $font-color-base;
  453. }
  454. .iconfont {
  455. font-size: 36rpx;
  456. }
  457. </style>