productdetails.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <view class="pages">
  3. <!-- <u-navbar
  4. title="产品详情"
  5. :placeholder="true"
  6. :autoBack="false"
  7. @leftClick="leftClick"
  8. :safeAreaInsetTop="true"
  9. >
  10. </u-navbar> -->
  11. <u-swiper
  12. v-if="details.slideImgList.length>0"
  13. :list="details.slideImgList"
  14. height="700rpx"
  15. @change="e => currentNum = e.current"
  16. :autoplay="false"
  17. indicatorStyle="right: 20px"
  18. >
  19. <view
  20. slot="indicator"
  21. class="indicator-num"
  22. >
  23. <text class="indicator-num__text">{{ currentNum + 1 }}/{{ details.slideImgList.length }}</text>
  24. </view>
  25. </u-swiper>
  26. <view class="product-info view-wrap">
  27. <view class="price u-flex u-row-between">
  28. <view class="u-flex">
  29. <img style="margin-right: 10rpx;" src="../static/img/integral-ico-y.png" alt="">
  30. {{details.exchangeCredit}}积分
  31. </view>
  32. <view class="exchange-num">已兑换{{details.saleCount}}</view>
  33. </view>
  34. <view class="name">{{details.goodsName}}</view>
  35. </view>
  36. <view class="specification info-line u-flex view-wrap" v-if="details.specification">
  37. <view class="info-til">规格</view>
  38. <view class="info-con u-flex">{{details.specification}}</view>
  39. </view>
  40. <!-- <view class="addr view-wrap" v-if="details.period">
  41. <view class="addr-line u-flex" v-if="details.period">
  42. <view class="info-til">保质期</view>
  43. <view class="info-con u-flex">
  44. {{details.period}}(天)
  45. </view>
  46. </view>
  47. </view> -->
  48. <view class="detail view-wrap">
  49. <view class="til">详情</view>
  50. <view class="con">
  51. <u-parse :content="details.detail"></u-parse>
  52. </view>
  53. </view>
  54. <view class="details-tool-wrap">
  55. <view class="details-tool">
  56. <view class="full-btn" @click="addCreditOrder">立即兑换</view>
  57. </view>
  58. </view>
  59. <u-popup :show="popupShow" mode="bottom" @close="close">
  60. <view class="select-num">
  61. <view class="header u-flex">
  62. <u-icon name="close" color="#666" size="28" @click="close"></u-icon>
  63. </view>
  64. <view class="select-wrap u-flex u-row-between">
  65. <view class="title">购买数量(件)</view>
  66. <u-number-box v-model="param.quantity" @change="quantityChange" :max="Math.floor(credit/details.exchangeCredit)"></u-number-box>
  67. </view>
  68. <view class="full-btn" @click="exchange">确定兑换</view>
  69. </view>
  70. </u-popup>
  71. <u-toast ref="uToast"></u-toast>
  72. </view>
  73. </template>
  74. <script>
  75. export default {
  76. data() {
  77. return {
  78. id:'',
  79. cartTotal:0,
  80. currentNum:0,
  81. swiperList: [],
  82. details:{
  83. slideImgList:[],
  84. exchangeCredit:1
  85. },
  86. credit:0,
  87. popupShow:false,
  88. param:{
  89. goodsId:'',
  90. quantity:1,
  91. }
  92. }
  93. },
  94. onLoad(page) {
  95. this.id = page.id;
  96. this.param.goodsId = page.id;
  97. // console.log('this.id',this.id);
  98. this.getDetails(this.id);
  99. this.getMemberCredit();
  100. },
  101. onShow(){
  102. // this.getCartList();
  103. // this.getAddrList();
  104. },
  105. methods: {
  106. leftClick(e){
  107. let pages = getCurrentPages();
  108. if(pages.length==1){
  109. uni.$u.route('/pages/index/index')
  110. }else{
  111. uni.navigateBack()
  112. };
  113. },
  114. getMemberCredit(){
  115. this.$u.api.memberCredit().then(res=>{
  116. this.credit = res.data.credit
  117. // console.log('memberCredit',this.credit);
  118. }).catch(err=>{
  119. console.log('memberCredit',err.data);
  120. })
  121. },
  122. getDetails(id){
  123. this.$u.api.memberGoodDetails({id:id}).then(res=>{
  124. // console.log('res',res.data);
  125. this.details = res.data;
  126. if(!res.data.slideImgList&&res.data.mainImg){
  127. this.details.slideImgList = [];
  128. this.details.slideImgList.push(res.data.mainImg)
  129. }
  130. }).catch(err=>{
  131. console.log('getDetails',err.data);
  132. })
  133. },
  134. addCreditOrder(id){
  135. this.popupShow = true
  136. },
  137. exchange(){
  138. // console.log('param',this.param);
  139. this.$u.api.exchangeGoods(this.param).then(res=>{
  140. this.close();
  141. uni.$u.route('/shopping/paysuccess', {
  142. codeData: res.data.exchangeCode,
  143. msg:res.msg,
  144. success:true
  145. });
  146. // console.log('exchangeGoods',res.data);
  147. }).catch(err=>{
  148. this.close();
  149. uni.$u.route('/shopping/paysuccess', {
  150. codeData: null,
  151. msg:err.msg,
  152. success:false
  153. });
  154. console.log('exchangeGoods',err.data);
  155. })
  156. },
  157. close() {
  158. this.popupShow = false
  159. },
  160. quantityChange(e){
  161. // console.log('quantityChange',e);
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. .indicator-num {
  168. padding: 2px 0;
  169. background-color: rgba(0, 0, 0, 0.35);
  170. border-radius: 100px;
  171. width: 35px;
  172. @include flex;
  173. justify-content: center;
  174. &__text {
  175. color: #FFFFFF;
  176. font-size: 12px;
  177. }
  178. }
  179. .product-info{
  180. .price{
  181. font-size: 44rpx;
  182. font-weight: 600;
  183. color: #FFB100;
  184. line-height: 60rpx;
  185. .exchange-num{
  186. font-size: 28rpx;
  187. font-weight: 400;
  188. color: #999999;
  189. line-height: 40rpx;
  190. }
  191. }
  192. .name{
  193. margin-top: 30rpx;
  194. font-size: 36rpx;
  195. font-weight: 600;
  196. color: #333;
  197. line-height: 50rpx;
  198. }
  199. }
  200. .info-line{
  201. margin-bottom: 20rpx;
  202. }
  203. .info-til{
  204. color: #999;
  205. margin-right: 40rpx;
  206. }
  207. .info-con{
  208. color: #666;
  209. }
  210. .addr{
  211. font-size: 30rpx;
  212. .addr-line:not(:last-child){
  213. }
  214. }
  215. .comment{
  216. color: #999;
  217. .til{
  218. font-size: 30rpx;
  219. font-weight: 600;
  220. margin-right: 20rpx;
  221. color: #333;
  222. }
  223. }
  224. .detail{
  225. .til{
  226. font-size: 30rpx;
  227. color: #333;
  228. font-weight: 600;
  229. margin-bottom: 20rpx;
  230. }
  231. .con{
  232. // background-color: #F5F5F5;
  233. img{max-width: 100%;}
  234. }
  235. }
  236. .details-tool-wrap{
  237. height: 98rpx;
  238. .details-tool{
  239. position: fixed;
  240. left: 0;
  241. right: 0;
  242. bottom: 0;
  243. height: 98rpx;
  244. background-color: #fff;
  245. }
  246. .left{
  247. text-align: center;
  248. color: #666;
  249. font-size: 24rpx;
  250. .icon-wrap{
  251. position: relative;
  252. margin-left: 20rpx;
  253. }
  254. }
  255. .right{
  256. .btn{
  257. padding: 10rpx 40rpx;
  258. border-radius: 40rpx;
  259. color: #fff;
  260. margin-right: 20rpx;
  261. font-size: 30rpx;
  262. }
  263. .add-btn{
  264. background-color: #FFB100;
  265. }
  266. .buy-btn{
  267. background-color: #FF3C3F;
  268. }
  269. .gray{
  270. background-color: #ddd;
  271. color: #999;
  272. }
  273. }
  274. }
  275. .full-btn{
  276. margin: 0;
  277. border-radius: 0;
  278. background-color: #009AEF;
  279. padding: 0;
  280. height: 98rpx;
  281. line-height: 98rpx;
  282. }
  283. .select-num{
  284. .header{
  285. padding: 30rpx 30rpx 0;
  286. text-align: right;
  287. justify-content: end;
  288. margin-bottom: 40rpx;
  289. }
  290. .select-wrap{
  291. padding: 30rpx;
  292. }
  293. }
  294. </style>