app-exclusive-coupon.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="app-exclusive-coupon" :style="{'background-color': `${noneColor ? '' : background}`}">
  3. <view class="app-top dir-left-nowrap main-between" v-if="showTop">
  4. <view class="app-left dir-left-nowrap main-between cross-center">
  5. <icon class="app-icon"></icon>
  6. <text class="app-title">专享优惠券</text>
  7. </view>
  8. <view class="app-right dir-left-nowrap main-between cross-center">
  9. <app-jump-button form url="/pages/coupon/list/list" open_type="navigate">
  10. <text class="app-text">更多</text>
  11. <icon class="app-icon"></icon>
  12. </app-jump-button>
  13. </view>
  14. </view>
  15. <view class="app-bottom">
  16. <scroll-view scroll-x class="app-scroll dir-left-nowrap">
  17. <view v-for="(item, index) in coupon_list"
  18. :key="index"
  19. class="app-item"
  20. :style="{backgroundImage: `url(${item.is_receive === '0' ? unclaimedBg : item.is_receive === '1' ? receiveBg : ''})`}"
  21. >
  22. <app-form-id @click="receive(index)">
  23. <view class="dir-left-nowrap main-left">
  24. <view class="app-text-left">
  25. <view class="app-text-top">
  26. <template v-if="item.type === '1'">
  27. <text class="app-number discount" :style="{color: textColor}">{{item.discount}}</text>
  28. </template>
  29. <template v-else>
  30. <text class="app-symbol" :style="{color: textColor}">¥</text>
  31. <text class="app-number" :style="{color: textColor}">{{item.sub_price}}</text>
  32. </template>
  33. </view>
  34. <text class="app-text-bottom" :style="{color: textColor}">满{{item.min_price}}元可用</text>
  35. </view>
  36. <view class="app-text-right">
  37. <text :style="{color: textColor}">{{item.is_receive === '0' ? receiveTip : item.is_receive > '0' ? '已领取' : ''}}</text>
  38. </view>
  39. </view>
  40. </app-form-id>
  41. </view>
  42. </scroll-view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. name: 'app-exclusive-coupon',
  49. props: {
  50. receiveBg: {
  51. type: String,
  52. default: function() {
  53. return '';
  54. }
  55. },
  56. textColor: {
  57. type: String,
  58. default: function() {
  59. return "#ffffff";
  60. }
  61. },
  62. unclaimedBg: {
  63. type: String,
  64. default: function() {
  65. return ''
  66. }
  67. },
  68. index: {
  69. type: Number,
  70. },
  71. sign: {
  72. type: String,
  73. },
  74. coupon_list: {
  75. type: Array,
  76. default: function() {
  77. return [
  78. ]
  79. }
  80. },
  81. showTop: {
  82. type: Boolean,
  83. default() {
  84. return true;
  85. }
  86. },
  87. noneColor: {
  88. type: Boolean,
  89. default() {
  90. return false;
  91. }
  92. }
  93. },
  94. data() {
  95. return {
  96. list: []
  97. };
  98. },
  99. watch: {
  100. coupon_list: {
  101. handler() {
  102. // this.list = this.coupon_list;
  103. },
  104. immediate: true
  105. }
  106. },
  107. computed: {
  108. receiveTip() {
  109. let receiveTip = '立即领取';
  110. if (this.sign === 'integral-mall') {
  111. receiveTip = '立即兑换';
  112. }
  113. return receiveTip;
  114. }
  115. },
  116. methods: {
  117. receive(index) {
  118. let list = this.coupon_list;
  119. if (this.sign == 'integral-mall') {
  120. this.$jump({
  121. url: list[index].page_url,
  122. open_type: 'navigate'
  123. });
  124. return ;
  125. }
  126. if (list[index].is_receive == 1) {
  127. uni.showToast({
  128. mask: true,
  129. title: '已领取',
  130. icon: 'none'
  131. });
  132. return true;
  133. }
  134. uni.showLoading({
  135. mask: true,
  136. title: '领取中'
  137. });
  138. this.$request({
  139. url: this.$api.coupon.receive,
  140. data: {
  141. coupon_id: list[index].id
  142. }
  143. }).then(e => {
  144. uni.hideLoading();
  145. if (e.code === 0) {
  146. list[index].is_receive = '1';
  147. this.$store.dispatch('page/actionSetCoupon', {
  148. list: [list[index]],
  149. type: 'receive'
  150. });
  151. this.list = list;
  152. }
  153. }).catch(() => {
  154. uni.hideLoading();
  155. });
  156. }
  157. }
  158. }
  159. </script>
  160. <style scoped lang="scss">
  161. .app-exclusive-coupon {
  162. width: #{750rpx};
  163. .app-top {
  164. width: #{750rpx};
  165. height: #{80rpx};
  166. border-bottom: #{1rpx} solid #e2e2e2;
  167. .app-icon {
  168. background-repeat: no-repeat;
  169. background-size: 100% 100%;
  170. }
  171. .app-left {
  172. width: #{215rpx};
  173. height: #{80rpx};
  174. margin-left: #{24rpx};
  175. .app-icon {
  176. width: #{46rpx};
  177. height: #{46rpx};
  178. background-image: url("../../../static/image/icon/coupon-icon.png");
  179. }
  180. .app-title {
  181. font-size: #{28rpx};
  182. color: #ff8831;
  183. }
  184. }
  185. .app-right {
  186. height: #{80rpx};
  187. width: #{75rpx};
  188. margin-right: #{24rpx};
  189. .app-icon {
  190. width: #{12rpx};
  191. height: #{22rpx};
  192. background-image: url("../../../static/image/icon/arrow-right.png");
  193. }
  194. .app-text {
  195. font-size: #{26rpx};
  196. color: #999999;
  197. }
  198. }
  199. }
  200. .app-bottom {
  201. padding-top: #{16rpx};
  202. padding-left: #{8rpx};
  203. padding-bottom: #{16rpx};
  204. height: #{130+16+16rpx};
  205. width: #{750rpx};
  206. .app-scroll {
  207. height: #{130+16+16rpx};
  208. width: #{750-24rpx};
  209. white-space: nowrap;
  210. }
  211. .app-item {
  212. width: #{256rpx};
  213. height: #{130rpx};
  214. display: inline-block;
  215. margin-left: #{16rpx};
  216. background-repeat: no-repeat;
  217. background-size: 100% 100%;
  218. >view {
  219. width: #{256rpx};
  220. height: #{130rpx};
  221. }
  222. .app-text-left {
  223. width: #{199rpx};
  224. height: #{130rpx};
  225. .app-text-top {
  226. height: #{78rpx};
  227. padding-top: #{1rpx};
  228. overflow: hidden;
  229. text-align: center;
  230. .app-symbol {
  231. display: inline-block;
  232. height: #{78rpx};
  233. font-size: #{20rpx};
  234. }
  235. .app-number {
  236. display: inline-block;
  237. height: #{78rpx};
  238. padding-top: #{26rpx};
  239. font-size: #{40rpx};
  240. width: #{159rpx};
  241. }
  242. .discount:after {
  243. content: '折';
  244. font-size: 75%;
  245. }
  246. }
  247. .app-text-bottom {
  248. height: #{50rpx};
  249. width: #{199rpx};
  250. text-align: center;
  251. font-size: #{20rpx};
  252. display: inline-block;
  253. }
  254. }
  255. .app-text-right {
  256. width: #{50rpx};
  257. height: #{130rpx};
  258. text {
  259. height: #{130rpx};
  260. width: #{50rpx};
  261. display: inline-block;
  262. text-align: center;
  263. line-height: #{50rpx};
  264. font-size: #{20rpx};
  265. margin-left: #{2rpx};
  266. writing-mode: vertical-rl;
  267. letter-spacing: #{5rpx};
  268. }
  269. }
  270. }
  271. }
  272. }
  273. </style>