user.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <view class="container">
  3. <view class="vheigh"></view>
  4. <view class="user-section">
  5. <view class="user-info-box ">
  6. <view class="avatar"><image class="avatarImg" :src="userInfo.avatar||'../../static/error/missing-face.png'" mode="widthFix"></image></view>
  7. <view class="username">
  8. {{userInfo.nickname}}
  9. </view>
  10. <view class="userphone" v-if="userInfo.phone">
  11. {{userInfo.phone|phoneXh}}
  12. </view>
  13. </view>
  14. <view class="rightBox">
  15. <view class="rz" v-if="userInfo.is_real">
  16. 已认证
  17. </view>
  18. <view class="card" v-if="userInfo.card_no">
  19. NO.{{userInfo.card_no}}
  20. </view>
  21. <view class="zc" v-if="userInfo.spread_store">
  22. {{userInfo.spread_store}}
  23. </view>
  24. </view>
  25. </view>
  26. <view class="cover-container">
  27. <view class="item-box">
  28. <view class="order-section">
  29. <view class="order-item" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover" :hover-stay-time="50">
  30. <view class=" icon position-relative">
  31. <image class="icon-img" src="/static/icon/u1.png" mode="aspectFit"></image>
  32. <view class="corner" v-if="orderInfo.unpaid_count > 0">
  33. <text>{{ orderInfo.unpaid_count }}</text>
  34. </view>
  35. </view>
  36. <text>待付款</text>
  37. </view>
  38. <view class="order-item" @click="navTo('/pages/order/order?state=1')" hover-class="common-hover" :hover-stay-time="50">
  39. <view class=" icon position-relative">
  40. <image class="icon-img" src="/static/icon/u2.png" mode="aspectFit"></image>
  41. <view class="corner" v-if="orderInfo.unshipped_count > 0">
  42. <text>{{ orderInfo.unshipped_count }}</text>
  43. </view>
  44. </view>
  45. <text>待发货</text>
  46. </view>
  47. <view class="order-item" @click="navTo('/pages/order/order?state=2')" hover-class="common-hover" :hover-stay-time="50">
  48. <view class="icon position-relative">
  49. <image class="icon-img" src="/static/icon/u3.png" mode="aspectFit"></image>
  50. <view class="corner" v-if="orderInfo.received_count > 0">
  51. <text>{{ orderInfo.received_count }}</text>
  52. </view>
  53. </view>
  54. <text>待收货</text>
  55. </view>
  56. <view class="order-item" @click="navTo('/pages/order/order?state=3')" hover-class="common-hover" :hover-stay-time="50">
  57. <view class="icon position-relative">
  58. <image class="icon-img" src="/static/icon/u4.png" mode="aspectFit"></image>
  59. <!-- <view class="corner" v-if="orderInfo.complete_count > 0">
  60. <text>{{ orderInfo.complete_count }}</text>
  61. </view> -->
  62. </view>
  63. <text>已完成</text>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 浏览历史 -->
  68. <view class="history-section icon">
  69. <uni-list>
  70. <uni-list-item title="我的积分" @click="navTo('/pages/money/wallet')" thumb="/static/icon/v1.png"></uni-list-item>
  71. <uni-list-item title="积分转账" @click="navTo('/pages/user/withdmoenys')" thumb="/static/icon/v2.png"></uni-list-item>
  72. <uni-list-item title="我的推广" @click="navTo('/pages/user/extension')" thumb="/static/icon/v3.png"></uni-list-item>
  73. <uni-list-item title="邀请海报" @click="navTo('/pages/user/shareQrCode')" thumb="/static/icon/v4.png"></uni-list-item>
  74. <uni-list-item title="收货地址" @click="navTo('/pages/set/address')" thumb="/static/icon/v5.png"></uni-list-item>
  75. <uni-list-item title="核销" @click="openQr" thumb="/static/icon/v5.png"></uni-list-item>
  76. <uni-list-item title="设置" @click="navTo('/pages/set/set')" thumb="/static/icon/v6.png"></uni-list-item>
  77. </uni-list>
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. import { mapState, mapMutations } from 'vuex';
  84. import uniList from '@/components/uni-list/uni-list.vue';
  85. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  86. import { orderData, getUserInfo,orderVerific } from '@/api/user.js';
  87. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  88. let startY = 0,
  89. moveY = 0,
  90. pageAtTop = true;
  91. export default {
  92. components: {
  93. uniList,
  94. uniListItem
  95. },
  96. data() {
  97. return {
  98. coverTransform: 'translateY(0px)',
  99. coverTransition: '0s',
  100. moving: false,
  101. userDowm: 0, //卡片升级专属高度
  102. userMaxDowm: 0 //卡片最高高度
  103. };
  104. },
  105. filters: {
  106. phoneXh: function(value) {
  107. let a = value.substring(3,8)
  108. return value.replace(a,'*****');
  109. }
  110. },
  111. onShow() {
  112. // 判断是否已经登录
  113. if (this.hasLogin) {
  114. this.loadBaseData();
  115. }
  116. },
  117. onReady() {
  118. // 初始化获取页面宽度
  119. uni.createSelectorQuery()
  120. .select('.container')
  121. .fields(
  122. {
  123. size: true
  124. },
  125. data => {
  126. // 计算最多下拉的高度
  127. this.userDowm = Math.floor((data.width / 750) * 185);
  128. // 计算最大触发修改高度事件
  129. this.userMaxDowm = Math.floor((data.width / 750) * 250);
  130. }
  131. )
  132. .exec();
  133. },
  134. computed: {
  135. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  136. },
  137. methods: {
  138. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  139. // 加载初始数据
  140. loadBaseData() {
  141. getUserInfo({})
  142. .then(({ data }) => {
  143. this.setUserInfo(data);
  144. if(+data.is_real!=1){
  145. uni.showModal({
  146. title: '提示',
  147. content: '为保护未成年人,未实名认证不可购买商品!',
  148. showCancel: false,
  149. success: res => {
  150. uni.navigateTo({
  151. url: '/pages/set/approve',
  152. });
  153. },
  154. });
  155. }
  156. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  157. orderData({})
  158. .then(({ data }) => {
  159. this.setOrderInfo(data);
  160. })
  161. .catch(e => {
  162. this.setOrderInfo({
  163. complete_count: 0, //完成
  164. received_count: 0, //待收货
  165. unshipped_count: 0, //待发货
  166. order_count: 0, //订单总数
  167. unpaid_count: 0 //待付款
  168. });
  169. });
  170. })
  171. .catch(e => {
  172. console.log(e);
  173. });
  174. },
  175. /**
  176. * 统一跳转接口,拦截未登录路由
  177. * navigator标签现在默认没有转场动画,所以用view
  178. */
  179. navTo(url) {
  180. if (!this.hasLogin) {
  181. // 保存地址
  182. saveUrl();
  183. // 登录拦截
  184. interceptor();
  185. } else {
  186. uni.navigateTo({
  187. url
  188. });
  189. }
  190. },
  191. // 核销
  192. openQr() {
  193. let obj = this;
  194. // #ifndef H5
  195. uni.scanCode({
  196. success(e) {
  197. obj.orderVerific(e.result);
  198. }
  199. });
  200. // #endif
  201. // #ifdef H5
  202. this.weichatObj.scanQRCode({
  203. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  204. scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  205. success: function(res) {
  206. obj.orderVerific(res.resultStr); // 当needResult 为 1 时,扫码返回的结果
  207. }
  208. });
  209. // #endif
  210. },
  211. // 核销请求
  212. orderVerific(data) {
  213. orderVerific({
  214. verify_code: data
  215. })
  216. .then(e => {
  217. uni.showModal({
  218. title: '核销',
  219. content: '已核销成功',
  220. showCancel: false
  221. });
  222. })
  223. .catch(e => {
  224. uni.showModal({
  225. title: '错误',
  226. content: JSON.stringify(e),
  227. showCancel: false
  228. });
  229. console.log(e);
  230. });
  231. }
  232. }
  233. };
  234. </script>
  235. <style lang="scss">
  236. page {
  237. height: 100%;
  238. }
  239. %flex-center {
  240. display: flex;
  241. flex-direction: column;
  242. justify-content: center;
  243. align-items: center;
  244. }
  245. %section {
  246. display: flex;
  247. justify-content: space-around;
  248. align-content: center;
  249. background: #fff;
  250. border-radius: 10rpx;
  251. }
  252. .container {
  253. height: 100%;
  254. background-color: $page-color-base;
  255. background: url(../../static/img/indexBg.png) no-repeat;
  256. background-size: 100% auto;
  257. padding-top: 130rpx;
  258. }
  259. .content-box {
  260. height: 100%;
  261. }
  262. .vheigh {
  263. height: var(--status-bar-height);
  264. background-color: $base-color;
  265. }
  266. .user-section {
  267. margin: 15rpx 30rpx 0;
  268. background: url(../../static/img/userBg.png) no-repeat;
  269. background-size: 100% auto;
  270. height: 235rpx;
  271. position: relative;
  272. .user-info-box {
  273. color: white;
  274. text-align: center;
  275. .avatar {
  276. text-align: center;
  277. width: 100%;
  278. .avatarImg {
  279. margin-top: -70rpx;
  280. width: 140rpx;
  281. height: 140rpx;
  282. border: 5px solid rgba($color: #ffffff, $alpha: 0.3);
  283. border-radius: 99rpx;
  284. background-color: #ffffff;
  285. }
  286. }
  287. .username{
  288. font-size: $font-base;
  289. }
  290. .userphone{
  291. font-size:18rpx;
  292. }
  293. }
  294. .rightBox{
  295. color: white;
  296. position: absolute;
  297. text-align: right;
  298. bottom: 0;
  299. right: 0;
  300. padding-right: 20rpx;
  301. padding-bottom: 10rpx;
  302. }
  303. }
  304. .vip-card-box {
  305. display: flex;
  306. flex-direction: column;
  307. color: #f7d680;
  308. height: 240rpx;
  309. background: linear-gradient(left, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.8));
  310. border-radius: 16rpx 16rpx 0 0;
  311. overflow: hidden;
  312. position: relative;
  313. padding: 20rpx 24rpx;
  314. .card-bg {
  315. position: absolute;
  316. top: 20rpx;
  317. right: 0;
  318. width: 380rpx;
  319. height: 260rpx;
  320. }
  321. .b-btn {
  322. position: absolute;
  323. right: 20rpx;
  324. top: 16rpx;
  325. width: 132rpx;
  326. height: 40rpx;
  327. text-align: center;
  328. line-height: 40rpx;
  329. font-size: 22rpx;
  330. color: #36343c;
  331. border-radius: 20px;
  332. background: linear-gradient(left, #f9e6af, #ffd465);
  333. z-index: 1;
  334. }
  335. .tit {
  336. font-size: $font-base + 2rpx;
  337. color: #f7d680;
  338. margin-bottom: 28rpx;
  339. .iconfont {
  340. color: #f6e5a3;
  341. margin-right: 16rpx;
  342. }
  343. }
  344. .e-b {
  345. font-size: $font-sm;
  346. color: #d8cba9;
  347. margin-top: 10rpx;
  348. }
  349. }
  350. .cover-container {
  351. padding: 0 30rpx;
  352. position: relative;
  353. padding-bottom: 20rpx;
  354. .arc {
  355. position: absolute;
  356. left: 0;
  357. top: -34rpx;
  358. width: 100%;
  359. height: 36rpx;
  360. }
  361. }
  362. .tj-sction {
  363. @extend %section;
  364. .tj-item {
  365. @extend %flex-center;
  366. flex-direction: column;
  367. height: 140rpx;
  368. font-size: $font-sm;
  369. color: #75787d;
  370. }
  371. .num {
  372. font-size: $font-lg;
  373. color: $font-color-dark;
  374. margin-bottom: 8rpx;
  375. }
  376. }
  377. .item-box {
  378. border-radius: 10rpx;
  379. background-color: white;
  380. margin-top: 20rpx;
  381. .box-title {
  382. line-height: 1;
  383. padding: 30rpx;
  384. .title {
  385. font-size: $font-lg;
  386. font-weight: bold;
  387. }
  388. .link {
  389. font-size: $font-base - 2rpx;
  390. color: $font-color-light;
  391. }
  392. }
  393. .order-section {
  394. @extend %section;
  395. padding: 28rpx 0;
  396. .order-item {
  397. @extend %flex-center;
  398. width: 120rpx;
  399. height: 120rpx;
  400. border-radius: 10rpx;
  401. font-size: $font-sm;
  402. color: $font-color-dark;
  403. }
  404. .iconfont {
  405. font-size: 48rpx;
  406. margin-bottom: 18rpx;
  407. color: #fa436a;
  408. }
  409. .icon-shouhoutuikuan {
  410. font-size: 44rpx;
  411. }
  412. .icon {
  413. height: 50rpx;
  414. width: 48rpx;
  415. margin-bottom: 18rpx;
  416. background-size: 100%;
  417. background-repeat: no-repeat;
  418. background-position: center;
  419. .icon-img {
  420. width: 100%;
  421. height: 100%;
  422. }
  423. }
  424. }
  425. }
  426. .history-section {
  427. // padding: 30rpx 0 0;
  428. margin-top: 20rpx;
  429. background: #fff;
  430. border-radius: 10rpx;
  431. overflow: hidden;
  432. .sec-header {
  433. display: flex;
  434. align-items: center;
  435. font-size: $font-base;
  436. color: $font-color-dark;
  437. line-height: 40rpx;
  438. margin-left: 30rpx;
  439. padding-top: 30rpx;
  440. .iconfont {
  441. font-size: 44rpx;
  442. color: $color-red;
  443. margin-right: 16rpx;
  444. line-height: 40rpx;
  445. }
  446. }
  447. .h-list {
  448. white-space: nowrap;
  449. padding: 30rpx 30rpx 0;
  450. .h-list-image {
  451. display: inline-block;
  452. width: 160rpx;
  453. height: 160rpx;
  454. margin-right: 20rpx;
  455. border-radius: 10rpx;
  456. }
  457. }
  458. }
  459. </style>