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

413 lines
8.3 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 weeks ago
3 weeks ago
3 weeks ago
3 weeks 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. comoId: this.selectedChargeId
  125. }
  126. await this.$fetch('addVip', params)
  127. // await uni.requestPaymentWxPay(res)
  128. uni.showToast({
  129. title: '充值成功',
  130. icon : 'none'
  131. })
  132. setTimeout(uni.navigateBack, 800, -1)
  133. } catch (err) {
  134. }
  135. return
  136. this.$api('addVip', res => {
  137. if(res.code == 200){
  138. uni.requestPaymentWxPay(res)
  139. .then(e => {
  140. uni.showToast({
  141. title: '下单成功',
  142. icon: 'none'
  143. })
  144. this.paySuccess(res)
  145. }).catch(n => {
  146. setTimeout(uni.redirectTo, 700, {
  147. url: '/pages/index/center'
  148. })
  149. })
  150. // uni.showToast({
  151. // title: '充值成功',
  152. // icon : 'none'
  153. // })
  154. setTimeout(uni.navigateBack, 800, -1)
  155. }
  156. })
  157. }
  158. }
  159. }
  160. </script>
  161. <style scoped lang="scss">
  162. $bar-height: 132rpx;
  163. .bg {
  164. width: 100vw;
  165. height: 550rpx;
  166. background-image: linear-gradient(#84A73F, #D8FF8F);
  167. }
  168. .page {
  169. padding-bottom: calc(#{$bar-height} + env(safe-area-inset-bottom));
  170. background-color: $uni-fg-color;
  171. min-height: 100vh;
  172. position: relative;
  173. }
  174. .content {
  175. position: absolute;
  176. top: 0;
  177. left: 0;
  178. width: 100vw;
  179. }
  180. .user {
  181. align-items: flex-start;
  182. color: $uni-text-color-inverse;
  183. font-size: 22rpx;
  184. margin: 34rpx 18rpx 0 18rpx;
  185. &-avatar {
  186. width: 147rpx;
  187. height: 147rpx;
  188. margin-right: 8rpx;
  189. }
  190. &-info {
  191. flex: 1;
  192. }
  193. &-name {
  194. font-size: 32rpx;
  195. margin-top: 16rpx;
  196. justify-content: flex-start;
  197. .icon {
  198. height: auto;
  199. &-role {
  200. width: 138rpx;
  201. }
  202. }
  203. }
  204. &-desc {
  205. margin-top: 26rpx;
  206. }
  207. }
  208. .consumption {
  209. margin: 0 28rpx;
  210. &-desc {
  211. color: $uni-text-color-inverse;
  212. font-size: 22rpx;
  213. margin-top: 1rpx;
  214. }
  215. }
  216. .charge {
  217. background-color: $uni-fg-color;
  218. border-top-left-radius: 18rpx;
  219. border-top-right-radius: 18rpx;
  220. margin-top: 45rpx;
  221. &-header {
  222. $header-height: 90rpx;
  223. height: $header-height;
  224. position: relative;
  225. &-title {
  226. width: calc(50% + 25rpx);
  227. height: 100%;
  228. color: $uni-text-color-inverse;
  229. font-size: 28rpx;
  230. background-image: linear-gradient(#84A73F, #D8FF8F);
  231. box-sizing: border-box;
  232. border-top-left-radius: 18rpx;
  233. border-bottom-right-radius: 90rpx;
  234. }
  235. &-mask {
  236. $marsk-width: 50rpx;
  237. position: absolute;
  238. top: 0;
  239. right: 50%;
  240. transform: translateX(25rpx);
  241. // height: 100%;
  242. // width: 70rpx;
  243. width: 0;
  244. height: 0;
  245. border-top: calc(#{$header-height}/2) solid transparent;
  246. border-left: calc(#{$marsk-width}/2) solid transparent;
  247. border-bottom: calc(#{$header-height}/2) solid $uni-fg-color;
  248. border-right: calc(#{$marsk-width}/2) solid $uni-fg-color;
  249. }
  250. }
  251. &-content {
  252. padding: 57rpx 14rpx;
  253. }
  254. &-selection {
  255. justify-content: space-between;
  256. font-size: 0;
  257. }
  258. &-option {
  259. width: 230rpx;
  260. height: 248rpx;
  261. box-sizing: border-box;
  262. background-color: #F5F5F5;
  263. border: 3rpx solid #C7C7C7;
  264. border-radius: 16rpx;
  265. box-shadow: 0rpx 3rpx 6rpx 0rpx #eef3e3;
  266. color: #999999;
  267. &-value {
  268. font-size: 61rpx;
  269. }
  270. &-unit {
  271. font-size: 34rpx;
  272. margin-right: 6rpx;
  273. }
  274. &.is-active {
  275. background-color: rgba($color: #E9FFC3, $alpha: 0.74);
  276. border-color: $uni-color-light;
  277. color: #F64041;
  278. }
  279. }
  280. &-rights {
  281. margin-top: 67rpx;
  282. &-header {
  283. .title {
  284. width: 202rpx;
  285. height: auto;
  286. }
  287. }
  288. &-content {
  289. margin-top: 31rpx;
  290. color: $uni-color-light;
  291. font-size: 28rpx;
  292. line-height: 66rpx;
  293. background-color: rgba($color: #E2FFAE, $alpha: 0.71);
  294. border-radius: 16rpx;
  295. padding: 29rpx 30rpx;
  296. width: 100%;
  297. min-height: 500rpx;
  298. box-sizing: border-box;
  299. position: relative;
  300. .icon {
  301. position: absolute;
  302. top: 23rpx;
  303. right: 11rpx;
  304. width: 131rpx;
  305. height: auto;
  306. }
  307. }
  308. }
  309. }
  310. // 下单
  311. .bar {
  312. position: fixed;
  313. z-index: 1000;
  314. bottom: 0;
  315. left: 0;
  316. width: 100vw;
  317. height: $bar-height;
  318. padding-bottom: env(safe-area-inset-bottom);
  319. background-color: $uni-fg-color;
  320. .count {
  321. flex: 1;
  322. color: #000000;
  323. font-size: 28rpx;
  324. margin-left: 48rpx;
  325. justify-content: flex-start;
  326. .price {
  327. color: #FF2A2A;
  328. font-size: 30rpx;
  329. &-unit {
  330. font-size: 18rpx;
  331. }
  332. }
  333. }
  334. .btn {
  335. border: none;
  336. line-height: 1;
  337. background-color: transparent;
  338. padding: 0;
  339. width: auto;
  340. height: auto;
  341. margin: 0;
  342. &-pay {
  343. margin-right: 41rpx;
  344. padding: 24rpx 137rpx;
  345. color: $uni-text-color-inverse;
  346. font-size: 28rpx;
  347. border-radius: 44rpx;
  348. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  349. }
  350. }
  351. }
  352. </style>