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

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