shop-gift-exchange.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <template>
  2. <view class="gift">
  3. <view class="top_box">
  4. <view class="top_circle"></view>
  5. <view class="gift_top">
  6. <image :src="gift.imgurl" class="gift_img" mode="aspectFill"></image>
  7. <view class="gift_title">{{gift.name}}</view>
  8. <view class="flexB" style="margin:30rpx 0;">
  9. <view class="gift_inte">
  10. <text>{{integral}}</text>
  11. <text>积分</text>
  12. </view>
  13. <view class="gift_num_box flexS">
  14. <view class="flexC" @click="down">-</view>
  15. <input type="number" v-model="num" @input="getVal" />
  16. <view class="flexC" @click="num++">+</view>
  17. </view>
  18. </view>
  19. <view class="sub_btn" @click="exchange">立即兑换</view>
  20. </view>
  21. </view>
  22. <view class="bottom_box">
  23. <view class="bottom_circle"></view>
  24. <view class="gift_bottom">
  25. <view>产品参数</view>
  26. <!-- <view>活动时间:2021/05/01-2012/05/06</view> -->
  27. <view>兑换形式:全部使用积分形式兑换</view>
  28. <view>本产品由大卫博士平台提供。本页面的信息以及服务由大卫博士交易平台提供,请确保账号处于正常状态。</view>
  29. </view>
  30. </view>
  31. <view class="hint_pop" v-if="hintShow">
  32. <view class="hint_con">
  33. <image src="../../static/imgs/shop/hint_icon.png" class="hint_icon"></image>
  34. <view class="hint_title">温馨提醒</view>
  35. <view class="hint_intr flexCC">{{hintCon}}</view>
  36. <view class="hint_btn_box flexC">
  37. <view @click="hintShow= false">取消</view>
  38. <view @click="exGift">确定</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. exchangeGifts
  47. } from '../../apis/shop.js'
  48. export default {
  49. data() {
  50. return {
  51. gift: '', //礼品详情
  52. num: 0,
  53. hintCon: '',
  54. hintShow: false,
  55. };
  56. },
  57. onLoad({
  58. gift
  59. }) {
  60. if (gift) {
  61. this.gift = JSON.parse(decodeURIComponent(gift))
  62. }
  63. },
  64. computed: {
  65. integral() {
  66. return this.num > 0 ? this.gift.integral * this.num : this.gift.integral
  67. }
  68. },
  69. methods: {
  70. //减号
  71. down() {
  72. if (this.num == 1) {
  73. uni.showToast({
  74. title: '兑换数量至少为1',
  75. icon: 'none'
  76. })
  77. return false;
  78. }
  79. this.num--;
  80. },
  81. //输入框获取数据
  82. getVal(e) {
  83. this.num = Number(e.detail.value)
  84. },
  85. //立即兑换
  86. exchange() {
  87. if (!this.num) {
  88. uni.showModal({
  89. content: '至少选择一件兑换',
  90. showCancel: false
  91. })
  92. return false;
  93. }
  94. this.hintShow = true;
  95. this.hintCon = `您确定使用${this.integral}积分兑换本商品吗?`
  96. },
  97. exGift() {
  98. this.hintShow = false
  99. uni.showLoading({
  100. title: '兑换中...'
  101. })
  102. exchangeGifts({
  103. gift_id: this.gift.id,
  104. num: this.num
  105. }).then(res => {
  106. if (res.code == 200) {
  107. uni.showModal({
  108. content: '兑换成功',
  109. showCancel: false,
  110. success: res => {
  111. if (res.confirm) {
  112. uni.redirectTo({
  113. url: '../shop-gift-suce/shop-gift-suce?integral=' +
  114. this.integral
  115. })
  116. }
  117. }
  118. })
  119. } else {
  120. uni.showModal({
  121. content: res.data || '兑换失败',
  122. showCancel: false
  123. })
  124. }
  125. uni.hideLoading()
  126. }).catch(err => {
  127. uni.hideLoading()
  128. })
  129. },
  130. }
  131. }
  132. </script>
  133. <style lang="scss">
  134. .hint_pop {
  135. width: 100vw;
  136. height: 100vh;
  137. background: rgba(0, 0, 0, 0.8);
  138. position: fixed;
  139. top: 0;
  140. left: 0;
  141. z-index: 99999;
  142. display: flex;
  143. flex-direction: column;
  144. justify-content: center;
  145. align-items: center;
  146. .hint_con {
  147. position: relative;
  148. width: 620rpx;
  149. text-align: center;
  150. margin: 0 auto;
  151. min-height: 384rpx;
  152. background: #fff;
  153. border-radius: 8rpx;
  154. display: flex;
  155. flex-direction: column;
  156. align-items: center;
  157. padding: 0 30rpx;
  158. .hint_title {
  159. font-size: 32rpx;
  160. font-weight: bold;
  161. margin-top: 85rpx;
  162. }
  163. .hint_intr {
  164. font-size: 32rpx;
  165. margin: 25rpx 0;
  166. min-height: 100rpx;
  167. }
  168. .hint_icon {
  169. width: 183rpx;
  170. height: 135rpx;
  171. position: absolute;
  172. top: -67rpx;
  173. margin-left: 18rpx;
  174. }
  175. .hint_btn_box {
  176. view {
  177. width: 242rpx;
  178. height: 88rpx;
  179. font-size: 32rpx;
  180. border-radius: 44rpx;
  181. text-align: center;
  182. line-height: 88rpx;
  183. }
  184. view:first-child {
  185. background: #E9E9E9;
  186. color: #999;
  187. margin-right: 15rpx;
  188. }
  189. view:last-child {
  190. background: $base-line-bg;
  191. color: #fff;
  192. }
  193. }
  194. }
  195. .iconfont {
  196. color: #fff;
  197. font-size: 60rpx;
  198. margin-top: 30rpx;
  199. }
  200. }
  201. .gift {
  202. width: 100vw;
  203. height: 100vh;
  204. background: linear-gradient(180deg, #FF232C 0%, #FF571B 100%);
  205. padding-top: 30rpx;
  206. }
  207. .top_box {
  208. width: 690rpx;
  209. height: 65vh;
  210. background: #fff;
  211. position: relative;
  212. margin: 0 auto 40rpx;
  213. border-radius: 24rpx 24rpx 0 0;
  214. }
  215. .bottom_box {
  216. width: 690rpx;
  217. height: 27vh;
  218. margin: 0 auto;
  219. background: #fff;
  220. position: relative;
  221. border-radius: 0 0 24rpx 24rpx;
  222. }
  223. .top_box,
  224. .bottom_box {
  225. padding: 0 30rpx;
  226. box-sizing: border-box;
  227. }
  228. .top_box {
  229. .gift_img {
  230. width: 630rpx;
  231. height: 504rpx;
  232. margin: 30rpx 0;
  233. border-radius: 24rpx;
  234. }
  235. .gift_title {
  236. font-size: 40rpx;
  237. font-weight: bold;
  238. }
  239. .gift_inte {
  240. text {
  241. color: $base-color;
  242. }
  243. text:first-child {
  244. font-size: 44rpx;
  245. font-weight: bold;
  246. }
  247. }
  248. .gift_num_box {
  249. width: 220rpx;
  250. height: 64rpx;
  251. background: #fff4f3;
  252. border: 2px solid $base-color;
  253. border-radius: 16rpx;
  254. overflow: hidden;
  255. input {
  256. border-left: 1rpx solid $base-color;
  257. border-right: 1rpx solid $base-color;
  258. height: 100%;
  259. width: 40%;
  260. text-align: center;
  261. }
  262. view {
  263. color: $base-color;
  264. width: 30%;
  265. font-size: 44rpx;
  266. flex-shrink: 0;
  267. }
  268. }
  269. .sub_btn {
  270. margin-bottom: 56rpx;
  271. }
  272. }
  273. .bottom_box {
  274. .gift_bottom {
  275. view:first-child {
  276. font-size: 32rpx;
  277. font-weight: bold;
  278. padding: 20rpx 0;
  279. }
  280. view {
  281. font-size: 28rpx;
  282. margin-bottom: 20rpx;
  283. }
  284. }
  285. }
  286. .top_circle,
  287. .bottom_circle {
  288. width: calc(100% - 40rpx);
  289. height: 20rpx;
  290. position: absolute;
  291. left: 20rpx;
  292. }
  293. .top_circle {
  294. background: #fff;
  295. bottom: -20rpx;
  296. border-bottom: 2rpx dotted #BFBFBF;
  297. }
  298. .bottom_circle {
  299. background: #fff;
  300. top: -20rpx;
  301. border-top: 2rpx dotted #BFBFBF;
  302. }
  303. .top_circle::before,
  304. .bottom_circle::before {
  305. content: '';
  306. position: absolute;
  307. width: 20rpx;
  308. height: 20rpx;
  309. left: -20rpx;
  310. }
  311. .top_circle::after,
  312. .bottom_circle::after {
  313. content: '';
  314. position: absolute;
  315. width: 20rpx;
  316. height: 20rpx;
  317. right: -20rpx;
  318. }
  319. .top_circle::before {
  320. background-image: radial-gradient(circle 20rpx at 0 100%, transparent 100rpx, #fff 50%);
  321. }
  322. .top_circle::after {
  323. background-image: radial-gradient(circle 20rpx at 100% 100%, transparent 100rpx, #fff 50%);
  324. }
  325. .bottom_circle::before {
  326. background-image: radial-gradient(circle 20rpx at 0 0, transparent 100rpx, #fff 50%);
  327. }
  328. .bottom_circle::after {
  329. background-image: radial-gradient(circle 20rpx at 100% 0, transparent 100rpx, #fff 50%);
  330. }
  331. </style>