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

395 lines
8.0 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <!-- 会员中心页面 -->
  2. <template>
  3. <view class="page">
  4. <view class="bg"></view>
  5. <view class="content">
  6. <!-- 导航栏 -->
  7. <navbar title="会员中心" leftClick @leftClick="$utils.navigateBack" bgColor="transparent" color="#fff" />
  8. <view class="flex user">
  9. <image class="user-avatar" :src="userInfo.headImage" mode="aspectFill"></image>
  10. <view class="user-info">
  11. <view class="flex user-name">
  12. <text>{{ userInfo.nickName }}</text>
  13. <template v-if="role === 'member-personal'">
  14. <image class="icon icon-role" src="@/static/image/center/icon-member-personal.png" mode="widthFix"></image>
  15. </template>
  16. <template v-else-if="role === 'member-business'">
  17. <image class="icon icon-role" src="@/static/image/center/icon-member-business.png" mode="widthFix"></image>
  18. </template>
  19. </view>
  20. <view class="user-desc">
  21. <template v-if="role">
  22. <!-- todo: 换回接口字段 -->
  23. <text>{{ `将于${'2026-12-12'} 到期` }}</text>
  24. </template>
  25. <template v-else>
  26. <text>暂未开通会员</text>
  27. </template>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="consumption" v-if="!role">
  32. <!-- todo: 对接接口 -->
  33. <progress :current="1000" :total="3800"></progress>
  34. <text class="consumption-desc">{{ `累积消费达到${3800}元或直接充值即可成为会员` }}</text>
  35. </view>
  36. <view class="charge">
  37. <view class="charge-header">
  38. <view class="flex charge-header-title">充值会员</view>
  39. <view class="charge-header-mask"></view>
  40. </view>
  41. <view class="charge-content">
  42. <view class="flex charge-selection">
  43. <view class="flex charge-option"
  44. v-for="item in chargeOptions"
  45. :key="item.id"
  46. :class="[selectedChargeId === item.id ? 'is-active' : '']"
  47. @click="onSelectCharge(item.id)"
  48. >
  49. <view class="charge-option-value">
  50. <text class="charge-option-unit">¥</text>
  51. <text>{{ item.price }}</text>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="charge-rights">
  56. <view class="flex charge-rights-header">
  57. <image class="title" src="../static/memberCenter/title-rights.png" mode="widthFix"></image>
  58. </view>
  59. <view class="charge-rights-content">
  60. <uv-parse :content="configList.config_rights"></uv-parse>
  61. <image class="icon" src="../static/memberCenter/icon-rights.png" mode="widthFix"></image>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="flex bar">
  68. <view class="flex count">
  69. <text>合计</text>
  70. <view class="price">
  71. <text class="price-unit">¥</text>
  72. <!-- todo: check -->
  73. <text>{{ totalPrice }}</text>
  74. </view>
  75. </view>
  76. <view class="btn btn-pay" @click="submit">
  77. 开通会员
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. import progress from '../components/progress.vue'
  84. import { mapGetters, mapState } from 'vuex'
  85. export default {
  86. name: "MemberCenter",
  87. components: {
  88. progress,
  89. },
  90. data() {
  91. return {
  92. chargeOptions: [],
  93. selectedChargeId: '001',
  94. }
  95. },
  96. onShow() {
  97. this.fetchCargeOptions()
  98. },
  99. computed: {
  100. ...mapGetters(['role']),
  101. ...mapState(['userInfo']),
  102. selectedChargeObj() {
  103. return this.chargeOptions.find(item => item.id === this.selectedChargeId)
  104. },
  105. totalPrice() {
  106. return this.selectedChargeObj?.price || 0
  107. }
  108. },
  109. methods: {
  110. async fetchCargeOptions() {
  111. try {
  112. this.chargeOptions = (await this.$fetch('queryComboList'))?.records || []
  113. this.selectedChargeId = this.chargeOptions?.[0]?.id
  114. } catch (err) {
  115. }
  116. },
  117. onSelectCharge(id) {
  118. this.selectedChargeId = id
  119. },
  120. async submit() {
  121. // todo: check jump to create order ?
  122. try {
  123. let params = {
  124. id: this.selectedChargeId
  125. }
  126. await this.$fetch('addVip', params)
  127. uni.showToast({
  128. title: '充值成功',
  129. icon : 'none'
  130. })
  131. setTimeout(uni.navigateBack, 800, -1)
  132. } catch (err) {
  133. }
  134. return
  135. this.$api('addVip', res => {
  136. if(res.code == 200){
  137. uni.showToast({
  138. title: '充值成功',
  139. icon : 'none'
  140. })
  141. setTimeout(uni.navigateBack, 800, -1)
  142. }
  143. })
  144. }
  145. }
  146. }
  147. </script>
  148. <style scoped lang="scss">
  149. $bar-height: 132rpx;
  150. .bg {
  151. width: 100vw;
  152. height: 550rpx;
  153. background-image: linear-gradient(#84A73F, #D8FF8F);
  154. }
  155. .page {
  156. padding-bottom: calc(#{$bar-height} + env(safe-area-inset-bottom));
  157. background-color: $uni-fg-color;
  158. min-height: 100vh;
  159. position: relative;
  160. }
  161. .content {
  162. position: absolute;
  163. top: 0;
  164. left: 0;
  165. width: 100vw;
  166. }
  167. .user {
  168. align-items: flex-start;
  169. color: $uni-text-color-inverse;
  170. font-size: 22rpx;
  171. margin: 34rpx 18rpx 0 18rpx;
  172. &-avatar {
  173. width: 147rpx;
  174. height: 147rpx;
  175. margin-right: 8rpx;
  176. }
  177. &-info {
  178. flex: 1;
  179. }
  180. &-name {
  181. font-size: 32rpx;
  182. margin-top: 16rpx;
  183. justify-content: flex-start;
  184. .icon {
  185. height: auto;
  186. &-role {
  187. width: 138rpx;
  188. }
  189. }
  190. }
  191. &-desc {
  192. margin-top: 26rpx;
  193. }
  194. }
  195. .consumption {
  196. margin: 0 28rpx;
  197. &-desc {
  198. color: $uni-text-color-inverse;
  199. font-size: 22rpx;
  200. margin-top: 1rpx;
  201. }
  202. }
  203. .charge {
  204. background-color: $uni-fg-color;
  205. border-top-left-radius: 18rpx;
  206. border-top-right-radius: 18rpx;
  207. margin-top: 45rpx;
  208. &-header {
  209. $header-height: 90rpx;
  210. height: $header-height;
  211. position: relative;
  212. &-title {
  213. width: calc(50% + 25rpx);
  214. height: 100%;
  215. color: $uni-text-color-inverse;
  216. font-size: 28rpx;
  217. background-image: linear-gradient(#84A73F, #D8FF8F);
  218. box-sizing: border-box;
  219. border-top-left-radius: 18rpx;
  220. border-bottom-right-radius: 90rpx;
  221. }
  222. &-mask {
  223. $marsk-width: 50rpx;
  224. position: absolute;
  225. top: 0;
  226. right: 50%;
  227. transform: translateX(25rpx);
  228. // height: 100%;
  229. // width: 70rpx;
  230. width: 0;
  231. height: 0;
  232. border-top: calc(#{$header-height}/2) solid transparent;
  233. border-left: calc(#{$marsk-width}/2) solid transparent;
  234. border-bottom: calc(#{$header-height}/2) solid $uni-fg-color;
  235. border-right: calc(#{$marsk-width}/2) solid $uni-fg-color;
  236. }
  237. }
  238. &-content {
  239. padding: 57rpx 14rpx;
  240. }
  241. &-selection {
  242. justify-content: space-between;
  243. font-size: 0;
  244. }
  245. &-option {
  246. width: 230rpx;
  247. height: 248rpx;
  248. box-sizing: border-box;
  249. background-color: #F5F5F5;
  250. border: 3rpx solid #C7C7C7;
  251. border-radius: 16rpx;
  252. box-shadow: 0rpx 3rpx 6rpx 0rpx #eef3e3;
  253. color: #999999;
  254. &-value {
  255. font-size: 61rpx;
  256. }
  257. &-unit {
  258. font-size: 34rpx;
  259. margin-right: 6rpx;
  260. }
  261. &.is-active {
  262. background-color: rgba($color: #E9FFC3, $alpha: 0.74);
  263. border-color: $uni-color-light;
  264. color: #F64041;
  265. }
  266. }
  267. &-rights {
  268. margin-top: 67rpx;
  269. &-header {
  270. .title {
  271. width: 202rpx;
  272. height: auto;
  273. }
  274. }
  275. &-content {
  276. margin-top: 31rpx;
  277. color: $uni-color-light;
  278. font-size: 28rpx;
  279. line-height: 66rpx;
  280. background-color: rgba($color: #E2FFAE, $alpha: 0.71);
  281. border-radius: 16rpx;
  282. padding: 29rpx 30rpx;
  283. width: 100%;
  284. min-height: 500rpx;
  285. box-sizing: border-box;
  286. position: relative;
  287. .icon {
  288. position: absolute;
  289. top: 23rpx;
  290. right: 11rpx;
  291. width: 131rpx;
  292. height: auto;
  293. }
  294. }
  295. }
  296. }
  297. // 下单
  298. .bar {
  299. position: fixed;
  300. z-index: 1000;
  301. bottom: 0;
  302. left: 0;
  303. width: 100vw;
  304. height: $bar-height;
  305. padding-bottom: env(safe-area-inset-bottom);
  306. background-color: $uni-fg-color;
  307. .count {
  308. flex: 1;
  309. color: #000000;
  310. font-size: 28rpx;
  311. margin-left: 48rpx;
  312. justify-content: flex-start;
  313. .price {
  314. color: #FF2A2A;
  315. font-size: 30rpx;
  316. &-unit {
  317. font-size: 18rpx;
  318. }
  319. }
  320. }
  321. .btn {
  322. border: none;
  323. line-height: 1;
  324. background-color: transparent;
  325. padding: 0;
  326. width: auto;
  327. height: auto;
  328. margin: 0;
  329. &-pay {
  330. margin-right: 41rpx;
  331. padding: 24rpx 137rpx;
  332. color: $uni-text-color-inverse;
  333. font-size: 28rpx;
  334. border-radius: 44rpx;
  335. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  336. }
  337. }
  338. }
  339. </style>