integralGoodsDetails.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <view class="content">
  3. <view class="cont-box">
  4. <view class="goods-banner" @click="showImg()">
  5. <swiper
  6. class="swiper"
  7. :indicator-dots="false"
  8. :circular="true"
  9. :autoplay="true"
  10. :interval="3000"
  11. :duration="1000"
  12. indicator-color="rgba(255, 255, 255, 0.6)"
  13. indicator-active-color="#ffffff"
  14. @change="swiperChange"
  15. >
  16. <swiper-item class="swiper-item" v-for="(item,index) in imgs" :key="index">
  17. <image :src="item" mode="aspectFit"></image>
  18. </swiper-item>
  19. </swiper>
  20. <!-- 数量 -->
  21. <view class="num-box">{{ activeImg }}/{{ imgs.length }}</view>
  22. </view>
  23. <view class="integral-box">
  24. <view class="title">{{item.goodsName}}</view>
  25. <view class="num-box">
  26. <view class="price" >{{item.integral}} 积分</view>
  27. <view class="count">原价:{{item.otPrice.toFixed(2)}}元</view>
  28. </view>
  29. </view>
  30. <view class="desc-box">
  31. <view class="desc" v-html="item.descs" >
  32. </view>
  33. </view>
  34. </view>
  35. <view class="btn-foot">
  36. <view class="p-price-box">
  37. <view class="p-name">兑换积分: </view>
  38. <view class="p-price" >{{item.integral}}</view>
  39. </view>
  40. <view class="btn-box">
  41. <view class="btn buy" @click="submit()" >
  42. 立即兑换
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {getIntegralGoodsById,createOrder} from '@/api/store.js'
  50. import {getUserInfo} from '@/api/user'
  51. export default {
  52. data() {
  53. return {
  54. imgs:[],
  55. activeImg: 1,
  56. goodsId:null,
  57. item:{},
  58. };
  59. },
  60. onLoad(option) {
  61. this.goodsId=option.goodsId;
  62. },
  63. onShow() {
  64. this.getIntegralGoodsById();
  65. },
  66. methods:{
  67. submit(){
  68. this.getUserInfo()
  69. },
  70. swiperChange(event) {
  71. this.activeImg = event.detail.current + 1
  72. },
  73. getUserInfo(){
  74. getUserInfo().then(
  75. res => {
  76. if(res.code==200){
  77. uni.navigateTo({
  78. url: "/pages_shopping/store/integralOrderPay?goodsId="+this.goodsId
  79. })
  80. if(res.user!=null){
  81. this.integral=res.user.integral;
  82. }
  83. }else{
  84. uni.showToast({
  85. icon:'none',
  86. title: "请求失败",
  87. });
  88. }
  89. },
  90. rej => {}
  91. );
  92. },
  93. showImg() {
  94. //预览图片
  95. uni.previewImage({
  96. urls: this.imgs,
  97. current: this.imgs[0]
  98. });
  99. },
  100. getIntegralGoodsById(){
  101. let data = {goodsId:this.goodsId};
  102. getIntegralGoodsById(data).then(
  103. res => {
  104. if(res.code==200){
  105. this.item=res.data;
  106. if(res.data.images!=null){
  107. this.imgs=res.data.images.split(",")
  108. }
  109. else{
  110. this.activeImg=0;
  111. }
  112. console.log(this.imgs)
  113. }else{
  114. uni.showToast({
  115. icon:'none',
  116. title: "请求失败",
  117. });
  118. }
  119. },
  120. rej => {}
  121. );
  122. },
  123. }
  124. }
  125. </script>
  126. <style lang="scss">
  127. page{
  128. height: 100%;
  129. }
  130. .content{
  131. height: 100%;
  132. display: flex;
  133. flex-direction: column;
  134. .cont-box{
  135. padding-bottom: 121rpx;
  136. .integral-box{
  137. background-color: #fff;
  138. padding: 20rpx;
  139. width: calc(100% - 40rpx);
  140. display: flex;
  141. flex-direction: column;
  142. align-items: flex-start;
  143. justify-content: flex-start;
  144. .title{
  145. font-weight: bold;
  146. font-size: 34upx;
  147. font-family: PingFang SC;
  148. color: #111;
  149. }
  150. .desc{
  151. margin-top: 15rpx;
  152. display: flex;
  153. align-items: flex-start;
  154. justify-content: flex-start;
  155. .cycle{
  156. background-color: #eee;
  157. border-radius: 30rpx;
  158. padding: 5rpx 15rpx;
  159. font-size: 26upx;
  160. font-family: PingFang SC;
  161. color: #FF5C03;
  162. }
  163. .duration{
  164. margin-left: 10rpx;
  165. background-color: #eee;
  166. border-radius: 30rpx;
  167. padding: 5rpx 15rpx;
  168. font-size: 26upx;
  169. font-family: PingFang SC;
  170. color: #FF5C03;
  171. }
  172. }
  173. .num-box{
  174. margin-top: 15rpx;
  175. flex: 1;
  176. display: flex;
  177. align-items: flex-end;
  178. justify-content: space-between;
  179. width: 100%;
  180. .price{
  181. padding: 5rpx 10rpx;
  182. background-color: #FF5C03;
  183. border-radius: 30rpx;
  184. font-size: 20upx;
  185. font-family: PingFang SC;
  186. color: #ffffff;
  187. }
  188. .count{
  189. font-size: 24upx;
  190. font-family: PingFang SC;
  191. color: #333333;
  192. }
  193. }
  194. }
  195. .desc-box{
  196. background-color: #fff;
  197. padding: 20rpx;
  198. margin-top: 10rpx;
  199. .title-box{
  200. display: flex;
  201. flex-direction: row;
  202. align-items: center;
  203. justify-content: flex-start;
  204. .title{
  205. font-size: 32upx;
  206. font-family: PingFang SC;
  207. font-weight: bold;
  208. color: #111111;
  209. }
  210. .line{
  211. margin-right: 15rpx;
  212. height: 30rpx;
  213. width: 6rpx;
  214. background-color: #FF5C03;
  215. }
  216. }
  217. .desc{
  218. margin-top: 15rpx;
  219. font-size: 28upx;
  220. font-family: PingFang SC;
  221. color: #9a9a9c;
  222. }
  223. }
  224. }
  225. }
  226. .btn-foot{
  227. box-sizing: border-box;
  228. width: 100%;
  229. height: 121upx;
  230. background: #FFFFFF;
  231. padding: 0 32upx 0 28upx;
  232. display: flex;
  233. align-items: center;
  234. justify-content: space-between;
  235. position: fixed;
  236. left: 0;
  237. bottom: 0;
  238. z-index: 99;
  239. .p-price-box{
  240. display: flex;
  241. align-items: center;
  242. .p-name{
  243. font-size: 28upx;
  244. font-family: PingFang SC;
  245. font-weight: 500;
  246. color: #666666;
  247. }
  248. .p-price{
  249. margin-left: 10rpx;
  250. color: #FF6633;
  251. font-size: 32upx;
  252. font-family: PingFang SC;
  253. font-weight: bold;
  254. }
  255. }
  256. .btn-box{
  257. display: flex;
  258. align-items: center;
  259. .btn{
  260. width: 200upx;
  261. height: 88upx;
  262. line-height: 88upx;
  263. text-align: center;
  264. border-radius: 44upx;
  265. margin-left: 20upx;
  266. font-size: 30upx;
  267. font-family: PingFang SC;
  268. font-weight: bold;
  269. color: #FFFFFF;
  270. &:first-child{
  271. margin-left: 0;
  272. }
  273. &.buy{
  274. background: #018C39;
  275. }
  276. }
  277. }
  278. }
  279. .goods-banner{
  280. height: 756upx;
  281. background-color: #FFFFFF;
  282. position: relative;
  283. .swiper-item{
  284. box-sizing: border-box;
  285. }
  286. .swiper,
  287. .swiper-item,
  288. .swiper-item image{
  289. width: 100%;
  290. height: 100%;
  291. }
  292. .num-box{
  293. width: 80upx;
  294. height: 44upx;
  295. line-height: 44upx;
  296. text-align: center;
  297. font-size: 24upx;
  298. font-family: PingFang SC;
  299. font-weight: 500;
  300. color: #FFFFFF;
  301. background: rgba(0, 0, 0, .3);
  302. border-radius: 22upx;
  303. position: absolute;
  304. right: 30upx;
  305. bottom: 30upx;
  306. z-index: 10;
  307. }
  308. }
  309. </style>