user.vue 11 KB

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