detail.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view :style="vuex_skin">
  3. <view class="goods">
  4. <image @click="$util.preview(detail.imgUrl)" :src="detail.imgUrl" style="width: 100vw;" mode="widthFix"></image>
  5. <view class="title">
  6. <view class="text-bold" style="color: #353535;font-family: PingFang-SC-Bold;font-size: 34rpx;">{{detail.name}}</view>
  7. <view class=" text-base" style="padding: 20rpx 0;">
  8. <view class="text-bold text-lg">
  9. {{detail.point}}
  10. <text style="padding-left: 6rpx;">积分</text>
  11. </view>
  12. </view>
  13. <block v-if="!$u.test.isEmpty(detail.content)">
  14. <view class="text-sm" style="color: #888888;line-height: 42rpx;">产品说明:{{detail.content}}</view>
  15. </block>
  16. </view>
  17. </view>
  18. <block v-if="exchangeShow">
  19. <view hover-class="none" class="container flex align-center justify-between"
  20. style="border-bottom: 1rpx solid #efefef;">
  21. <view class="flex padding align-center">
  22. <image src="@/static/mine/address.png" style="width: 65upx;height: 65upx;"></image>
  23. <view class="padding-left text-sm" v-if="!$u.test.isEmpty(address)">
  24. <view style="font-size: 28upx;font-family: PingFang SC;font-weight: 800;color: #000000;">
  25. {{address.consignee}} {{address.phone}}
  26. </view>
  27. <view class="text-gray">{{address.address}}</view>
  28. </view>
  29. <view class="padding-left"
  30. style="font-size: 28upx;font-family: PingFang SC;font-weight: 800;color: #000000;" v-else>
  31. 请选择收货地址</view>
  32. </view>
  33. <view class="padding">
  34. <u-icon name="arrow-right" color="#d4d4d4"></u-icon>
  35. </view>
  36. </view>
  37. <view class="padding-sm">
  38. <view class="flex padding-xs">
  39. <text class="flex justify-center align-center">积分数:</text>
  40. <u-number-box :disabled="$u.test.isEmpty(userInfo.pufaPoint)" @change="pufaPointChange"
  41. :input-width="200" :min="0" v-model="data.pufaPoint">
  42. </u-number-box>
  43. </view>
  44. </view>
  45. </block>
  46. <view class="" style="height: 140rpx;">
  47. </view>
  48. <view v-if="!exchangeShow" class="footer-fixed flex align-center justify-end padding bg-white"
  49. style="padding: 30rpx;;border-top: 1rpx solid #e5e5e5;z-index: 9;">
  50. <button class="cu-btn round text-white bg-base" style="width: 180upx;height: 80upx;"
  51. @click="$refs.toast.info('暂未开放')">兑换</button>
  52. </view>
  53. <view v-else class="footer-fixed flex align-center justify-between bg-white"
  54. style="border-top: 1rpx solid #e5e5e5;padding: 30rpx;z-index: 9;">
  55. <view class="text-red">
  56. <text>需支付</text>
  57. <text>¥</text>
  58. <text>{{cashValue}}</text>
  59. </view>
  60. <view>
  61. <button class="cu-btn round text-white bg-base" style="width: 180upx;height: 80upx;margin-right: 10upx;"
  62. @click="confirm">兑换</button>
  63. <button @click="exchangeShow = false" class="cu-btn round line-gray"
  64. style="width: 180upx;height: 80upx;z-index: 99;">取消</button>
  65. </view>
  66. </view>
  67. <login ref="login" @signIn="signIn" @phoneSuccess="phoneSuccess"></login>
  68. <toast ref="toast" ></toast>
  69. </view>
  70. </template>
  71. <script>
  72. export default {
  73. data() {
  74. return {
  75. id: '',
  76. //商品详情
  77. detail: {},
  78. //商品地址
  79. address: {},
  80. //用户信息
  81. userInfo: {},
  82. //点击兑换
  83. exchangeShow: false,
  84. //兑换的积分数
  85. cashValue: 0,
  86. data: {
  87. pufaPoint: 0
  88. },
  89. }
  90. },
  91. onLoad(options) {
  92. this.id = options.id;
  93. if (this.$u.test.isEmpty(this.id)) {
  94. this.$u.toast('商品id不能为空')
  95. return
  96. }
  97. this.fetchGoodsDetail()
  98. this.fetchUserInfo()
  99. },
  100. onShow() {
  101. this.getAddress()
  102. },
  103. methods: {
  104. pufaPointChange(e) {
  105. },
  106. /**
  107. * 获取用户信息
  108. */
  109. fetchUserInfo() {
  110. if (this.$cache.get('userInfo')) {
  111. this.userInfo = this.$cache.get('userInfo')
  112. return
  113. }
  114. if (this.$isEmpty(this.vuex_userId)) {
  115. this.showLogin()
  116. return
  117. }
  118. let params = {
  119. id: this.vuex_userId
  120. }
  121. this.$api.loginUser.detail(params).then(res => {
  122. this.userInfo = res.data.data
  123. })
  124. },
  125. /**
  126. * 获取用户地址
  127. */
  128. getAddress() {
  129. this.$api.address.list({
  130. userId: this.vuex_userId
  131. }).then(res => {
  132. this.address = res.data.data.records[0];
  133. })
  134. },
  135. /**
  136. * 获取商品详情
  137. */
  138. fetchGoodsDetail() {
  139. let params = {
  140. id: this.id
  141. }
  142. this.$api.pointgoods.list(params).then(res=>{
  143. this.detail=res.data.data.records[0]
  144. })
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss">
  150. page {
  151. background-color: #FFFFFF;
  152. }
  153. .goods {
  154. padding-bottom: 20rpx;
  155. border-bottom: 1rpx solid #efefef;
  156. .title {
  157. padding-top: 20rpx;
  158. margin-left: 20rpx;
  159. font-size: 32rpx;
  160. color: #363636;
  161. }
  162. }
  163. </style>