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

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