推拿小程序前端代码仓库
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.

594 lines
15 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. <template>
  2. <view class="page">
  3. <view class="flex flex-column header">
  4. <!-- 未登录显示 -->
  5. <view v-if="!isLogin" class="flex flex-column no-login">
  6. <view class="no-login-text">登录后查看个人信息</view>
  7. <button class="no-login-btn" @click="$utils.toLogin">立即登录</button>
  8. </view>
  9. <!-- 登录后显示用户信息 -->
  10. <view v-else class="flex flex-column user">
  11. <image class="user-avatar" :src="userInfo.headImage" mode="aspectFill"></image>
  12. <view class="user-name">{{ userInfo.nickName }}</view>
  13. </view>
  14. <view class="member">
  15. <view class="flex member-overview" :class="[role ? 'is-member' : '']">
  16. <template v-if="role">
  17. <!-- todo: 缺切图 "皇冠" -->
  18. <image class="icon icon-crown" src="" mode="widthFix"></image>
  19. <image v-if="role" class="icon icon-role" :src="vipInfo.massageVipCombo.imageVip" mode="widthFix"></image>
  20. <text v-if="vipInfo.validTime" class="member-tips">{{ `将于${$dayjs(vipInfo.validTime).format('YYYY-MM-DD')}到期` }}</text>
  21. </template>
  22. <template v-else>
  23. <view class="flex">
  24. <!-- todo: 缺切图 "皇冠" -->
  25. <image class="icon icon-crown" src="" mode="widthFix"></image>
  26. <!-- todo: 缺切图 "会员" -->
  27. <image class="icon icon-member" src="" mode="widthFix"></image>
  28. <text class="member-tips">成为会员可获得会员卡享受会员福利哟~</text>
  29. </view>
  30. <button plain class="btn member-btn" @click="$utils.navigateTo('/pages_order/mine/memberCenter')">立即开通</button>
  31. </template>
  32. </view>
  33. <view class="member-rights">
  34. <image class="member-rights-bg" src="@/pages_order/static/center/member-bg.png" mode="top" ></image>
  35. <view class="flex member-rights-content">
  36. <view class="flex">
  37. <image class="icon icon-rights" src="@/static/image/center/icon-member-weal.png" mode="widthFix"></image>
  38. <view>
  39. <view class="member-rights-label">会员福利</view>
  40. <view class="member-rights-value">会员折扣</view>
  41. </view>
  42. </view>
  43. <view class="flex">
  44. <!-- todo: 缺切图 -->
  45. <image class="icon icon-rights" src="@/static/image/center/icon-member-weal.png" mode="widthFix"></image>
  46. <view>
  47. <view class="member-rights-label">会员积分</view>
  48. <view class="member-rights-value">兑换礼品</view>
  49. </view>
  50. </view>
  51. <!-- todo: 缺切图 -->
  52. <view class="flex">
  53. <image class="icon icon-rights" src="@/static/image/center/icon-member-weal.png" mode="widthFix"></image>
  54. <view>
  55. <view class="member-rights-label">会员优惠券</view>
  56. <view class="member-rights-value">满减折扣</view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 账户信息 - 登录后显示 -->
  64. <view class="card flex account">
  65. <view class="flex flex-column">
  66. <view class="account-value">{{ userInfo.price || 0 }}<text class="account-unit"></text></view>
  67. <view class="account-label">我的余额</view>
  68. </view>
  69. <view class="flex flex-column">
  70. <view class="account-value">{{ userCenterData.score || 0 }}</view>
  71. <view class="account-label">我的积分</view>
  72. </view>
  73. <view class="flex flex-column">
  74. <view class="account-value">{{ userInfo.recommendAmount || 0 }}<text class="account-unit"></text></view>
  75. <view class="account-label">推广佣金</view>
  76. </view>
  77. <view class="flex flex-column">
  78. <view class="account-value">{{ couponCount || 0 }}<text class="account-unit"></text></view>
  79. <view class="account-label">优惠券</view>
  80. </view>
  81. </view>
  82. <view class="card fun-common">
  83. <view v-if="isMerchants" class="fun-header">
  84. <cardTitle>常用功能</cardTitle>
  85. </view>
  86. <view class="fun-content fun-common-content">
  87. <view class="flex flex-column" @click="$utils.navigateTo('/pages_order/mine/memberCenter')">
  88. <image class="fun-common-icon" src="@/static/image/center/icon-member-center.png" mode="widthFix"></image>
  89. <text class="fun-common-label">会员中心</text>
  90. </view>
  91. <view class="flex flex-column" @click="$utils.navigateTo('/pages_order/mine/partner')">
  92. <image class="fun-common-icon" src="@/static/image/center/icon-team.png" mode="widthFix"></image>
  93. <text class="fun-common-label">我的团队</text>
  94. </view>
  95. <!-- #ifdef MP-WEIXIN -->
  96. <view class="flex flex-column" @click="$utils.navigateTo('/pages_order/mine/promotion')">
  97. <!-- #endif -->
  98. <!-- #ifdef H5 -->
  99. <view class="flex flex-column" @click="$utils.navigateTo('/pages_order/mine/promotionH5')">
  100. <!-- #endif -->
  101. <image class="fun-common-icon" src="@/static/image/center/icon-invite.png" mode="widthFix"></image>
  102. <text class="fun-common-label">邀请好友</text>
  103. </view>
  104. <view class="flex flex-column" @click="$utils.navigateTo('/pages_order/mine/coupon')">
  105. <image class="fun-common-icon" src="@/static/image/center/icon-coupon.png" mode="widthFix"></image>
  106. <text class="fun-common-label">优惠券</text>
  107. </view>
  108. <view class="flex flex-column" @click="$utils.navigateTo('/pages_order/mine/voucher')">
  109. <image class="fun-common-icon" src="@/static/image/center/icon-voucher.png" mode="widthFix"></image>
  110. <text class="fun-common-label">代金券</text>
  111. </view>
  112. <!-- todo: check -> @click="openServicePopup" -->
  113. <view class="flex flex-column" @click="$utils.navigateTo('/pages_order/home/contact')">
  114. <image class="fun-common-icon" src="@/static/image/center/icon-service.png" mode="widthFix"></image>
  115. <text class="fun-common-label">联系客服</text>
  116. </view>
  117. <view class="flex flex-column" @click="$utils.navigateTo('/pages_order/mine/signIn')">
  118. <image class="fun-common-icon" src="@/static/image/center/icon-sign-in.png" mode="widthFix"></image>
  119. <text class="fun-common-label">每日签到</text>
  120. </view>
  121. <view class="flex flex-column" @click="$utils.navigateTo('/pages_order/mine/cooperation')">
  122. <image class="fun-common-icon" src="@/static/image/center/icon-cooperation.png" mode="widthFix"></image>
  123. <text class="fun-common-label">商家合作</text>
  124. </view>
  125. </view>
  126. </view>
  127. <view v-if="isMerchants" class="card fun-merchant">
  128. <view class="fun-header">
  129. <cardTitle>商家功能</cardTitle>
  130. </view>
  131. <view class="flex fun-content fun-merchant-content">
  132. <view class="left" @click="$utils.navigateTo('/pages_order/mine/verifyRecord')">
  133. <image class="left-bg" src="@/static/image/center/bg-verify.png"></image>
  134. <view class="flex left-content">
  135. <text>核销明细</text>
  136. <image class="left-icon" src="@/static/image/center/icon-arrow.png" mode="widthFix"></image>
  137. </view>
  138. </view>
  139. <!-- todo -->
  140. <view class="right" @click="onScan">
  141. <image class="right-bg" src="@/static/image/center/bg-scan.png"></image>
  142. </view>
  143. </view>
  144. </view>
  145. <customerServicePopup ref="customerServicePopup" />
  146. <tabber select="center" />
  147. </view>
  148. </template>
  149. <script>
  150. import cardTitle from '@/components/base/cardTitle.vue'
  151. import tabber from '@/components/base/tabbar.vue'
  152. import { mapGetters, mapState } from 'vuex'
  153. import customerServicePopup from '@/components/config/customerServicePopup.vue'
  154. export default {
  155. components: {
  156. cardTitle,
  157. tabber,
  158. customerServicePopup,
  159. },
  160. computed: {
  161. ...mapGetters(['role']),
  162. ...mapState(['userInfo', 'userCenterData', 'vipInfo', 'riceInfo']),
  163. isMerchants() {
  164. return this.userInfo.isMerchants === '1'
  165. },
  166. isLogin() {
  167. return this.userInfo && this.userInfo.id
  168. }
  169. },
  170. data() {
  171. return {
  172. couponCount: 0,
  173. }
  174. },
  175. onShow() {
  176. if(uni.getStorageSync('token')){
  177. this.$store.commit('getUserInfo')
  178. this.$store.commit('getUserCenterInfo')
  179. this.$store.commit('getRiceInfo')
  180. this.fetchCouponData()
  181. }
  182. },
  183. methods: {
  184. // #ifdef H5
  185. // 检查是否在微信环境
  186. isInWechat() {
  187. const ua = navigator.userAgent.toLowerCase()
  188. return ua.indexOf('micromessenger') !== -1
  189. },
  190. // #endif
  191. clickNo() {
  192. uni.showModal({
  193. title: '暂未开放',
  194. })
  195. },
  196. logout(){
  197. uni.showModal({
  198. title: '确认退出登录吗',
  199. success : (r) => {
  200. if (r.confirm) {
  201. this.$store.commit('logout', true)
  202. }
  203. }
  204. })
  205. },
  206. openServicePopup(phone, title) {
  207. // todo
  208. this.$refs.customerServicePopup.open(phone, title)
  209. },
  210. onScan() {
  211. // #ifdef H5
  212. // H5环境下使用微信JSSDK扫码
  213. if (!this.isInWechat()) {
  214. uni.showToast({
  215. title: '请在微信中打开',
  216. icon: 'none'
  217. })
  218. return
  219. }
  220. if (this.$jWeixin) {
  221. this.$jWeixin.ready(() => {
  222. this.$jWeixin.scanQRCode({
  223. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果
  224. scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  225. success: (res) => {
  226. console.log('H5扫码结果:', res);
  227. if (res.resultStr) {
  228. // 处理扫码结果
  229. const [id, type] = res.resultStr.split(',')
  230. console.log('扫码结果:', res.resultStr);
  231. this.$fetch('overOrder', {
  232. orderId : id,
  233. type, // type区分,0-订单核销 1-代金券核销
  234. }).then(() => {
  235. uni.showToast({
  236. title: '核销成功',
  237. icon: 'none'
  238. })
  239. }).catch(err => {
  240. uni.showToast({
  241. title: '核销失败',
  242. icon: 'none'
  243. })
  244. })
  245. }
  246. },
  247. fail: (err) => {
  248. console.error('H5扫码失败:', err);
  249. uni.showToast({
  250. title: '扫码失败',
  251. icon: 'none'
  252. })
  253. }
  254. })
  255. })
  256. this.$jWeixin.error((res) => {
  257. console.error('微信配置失败:', res)
  258. uni.showToast({
  259. title: '微信配置失败',
  260. icon: 'none'
  261. })
  262. })
  263. } else {
  264. uni.showToast({
  265. title: '微信环境异常',
  266. icon: 'none'
  267. })
  268. }
  269. // #endif
  270. // #ifdef MP-WEIXIN
  271. // 小程序环境下使用uni.scanCode
  272. uni.scanCode({
  273. success: (res) => {
  274. console.log(res);
  275. if (res.result) {
  276. // 处理扫码结果
  277. const [id, type] = res.result.split(',')
  278. console.log('扫码结果:', res.result);
  279. this.$fetch('overOrder', {
  280. orderId : id,
  281. type, // type区分,0-订单核销 1-代金券核销
  282. }).then(() => {
  283. uni.showToast({
  284. title: '核销成功',
  285. icon: 'none'
  286. })
  287. }).catch(err => {
  288. uni.showToast({
  289. title: '核销失败',
  290. icon: 'none'
  291. })
  292. })
  293. }
  294. },
  295. fail: (err) => {
  296. console.error('扫码失败:', err);
  297. uni.showToast({
  298. title: '扫码失败',
  299. icon: 'none'
  300. })
  301. }
  302. });
  303. // #endif
  304. },
  305. async fetchCouponData() {
  306. try {
  307. const { total } = await this.$fetch('queryVouchersList', { type: 0 })
  308. this.couponCount = total
  309. } catch (err) {
  310. }
  311. },
  312. }
  313. }
  314. </script>
  315. <style scoped lang="scss">
  316. .page {
  317. background-color: #F5F5F5;
  318. .header {
  319. height: 550rpx;
  320. background-image: linear-gradient(#84A73F, #D8FF8F);
  321. justify-content: flex-start;
  322. position: relative;
  323. }
  324. }
  325. .user {
  326. margin-top: 123rpx;
  327. &-avatar {
  328. width: 115rpx;
  329. height: 115rpx;
  330. border-radius: 50%;
  331. }
  332. &-name {
  333. margin-top: 4rpx;
  334. color: $uni-text-color-inverse;
  335. font-size: 30rpx;
  336. text-align: center;
  337. }
  338. }
  339. .no-login {
  340. margin-top: 123rpx;
  341. align-items: center;
  342. &-img {
  343. width: 115rpx;
  344. height: auto;
  345. margin-bottom: 20rpx;
  346. }
  347. &-text {
  348. color: #FFFFFF;
  349. font-size: 28rpx;
  350. margin-bottom: 40rpx;
  351. }
  352. &-btn {
  353. padding: 16rpx 60rpx;
  354. background-color: #FFFFFF;
  355. color: #84A73F;
  356. font-size: 28rpx;
  357. font-weight: bold;
  358. border-radius: 40rpx;
  359. box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
  360. }
  361. }
  362. .member {
  363. width: calc(724rpx);
  364. position: absolute;
  365. bottom: 0;
  366. left: 13rpx;
  367. color: #F5F5F5;
  368. font-size: 22rpx;
  369. background-color: #2B2C30;
  370. border-top-left-radius: 20rpx;
  371. border-top-right-radius: 20rpx;
  372. &-overview {
  373. min-height: 81rpx;
  374. justify-content: space-between;
  375. &.is-member {
  376. justify-content: flex-start;
  377. }
  378. }
  379. .icon {
  380. height: auto;
  381. &-crown {
  382. width: 35rpx;
  383. margin-left: 20rpx;
  384. }
  385. &-member {
  386. width: 62rpx;
  387. }
  388. &-role {
  389. width: 156rpx;
  390. margin-right: 15rpx;
  391. }
  392. &-rights {
  393. width: 56rpx;
  394. margin-right: 11rpx;
  395. }
  396. }
  397. &-btn {
  398. padding: 9rpx 17rpx;
  399. color: #000000;
  400. font-size: 22rpx;
  401. background-image: linear-gradient(131deg, #F8EDE1, #B3997E);
  402. box-shadow: 0rpx 3rpx 6rpx 0rpx rgba(0,0,0,0.16);
  403. border-radius: 24rpx;
  404. margin-right: 18rpx;
  405. }
  406. &-tips {
  407. margin-left: 6rpx;
  408. }
  409. &-rights {
  410. background-color: #37393D;
  411. position: relative;
  412. width: 100%;
  413. height: 142rpx;
  414. box-sizing: border-box;
  415. &-bg {
  416. width: 100%;
  417. height: 100%;
  418. }
  419. &-content {
  420. position: absolute;
  421. bottom: 0;
  422. width: 100%;
  423. height: 100%;
  424. box-sizing: border-box;
  425. padding: 0 35rpx 6rpx 35rpx;
  426. justify-content: space-between;
  427. }
  428. &-label {
  429. color: #CBAD8F;
  430. font-size: 22rpx;
  431. font-weight: 700;
  432. }
  433. &-value {
  434. color: #F5F5F5;
  435. font-size: 18rpx;
  436. }
  437. }
  438. }
  439. .card {
  440. margin: 20rpx 13rpx 0 13rpx;
  441. }
  442. .account {
  443. padding: 40rpx 40rpx 23rpx 40rpx;
  444. justify-content: space-between;
  445. &-label {
  446. color: #666666;
  447. font-size: 28rpx;
  448. margin-top: 9rpx;
  449. }
  450. &-value {
  451. color: #000000;
  452. font-size: 32rpx;
  453. }
  454. &-unit {
  455. color: #666666;
  456. font-size: 18rpx;
  457. margin-left: 2rpx;
  458. }
  459. }
  460. .fun {
  461. &-header {
  462. text-align: left;
  463. padding-left: 12rpx;
  464. margin-bottom: 19rpx;
  465. /deep/ .title__view {
  466. display: inline-flex;
  467. }
  468. }
  469. &-content {
  470. margin-top: 24rpx;
  471. }
  472. &-common {
  473. padding: 30rpx 40rpx 67rpx 40rpx;
  474. &-content {
  475. display: grid;
  476. grid-template-columns: repeat(4, 1fr);
  477. grid-column-gap: 71rpx;
  478. grid-row-gap: 81rpx;
  479. }
  480. &-icon {
  481. width: 66rpx;
  482. height: auto;
  483. }
  484. &-label {
  485. color: #000000;
  486. font-size: 28rpx;
  487. margin-top: 5rpx;
  488. }
  489. }
  490. &-merchant {
  491. padding: 33rpx 30rpx 28rpx 30rpx;
  492. margin-bottom: 10rpx;
  493. &-content {
  494. justify-content: space-between;
  495. }
  496. .left {
  497. width: 198rpx;
  498. height: 139rpx;
  499. position: relative;
  500. &-bg {
  501. width: 100%;
  502. height: 100%;
  503. }
  504. &-content {
  505. position: absolute;
  506. top: 13rpx;
  507. left: 14rpx;
  508. color: $uni-text-color-inverse;
  509. font-size: 28rpx;
  510. }
  511. &-icon {
  512. width: 23rpx;
  513. height: auto;
  514. margin-left: 9rpx;
  515. }
  516. }
  517. .right {
  518. width: 429rpx;
  519. height: 164rpx;
  520. margin-top: -25rpx;
  521. &-bg {
  522. width: 100%;
  523. height: 100%;
  524. }
  525. }
  526. }
  527. }
  528. </style>