index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view class="component-wrapper" :style="wrapper_style">
  3. <view v-if="datas.show_title" class="morebox">
  4. <view :style="title_style" class="title">{{ title }}</view>
  5. <view class="title2" @click="more">查看更多
  6. <u-icon :style="img_style2" color="#949494" name="arrow-right" size="14"></u-icon>
  7. </view>
  8. </view>
  9. <view>
  10. <view class="box1" v-if="show==1">
  11. <view class="coupon" :style="coupon" v-for="(item, index) in list" :key="item.id">
  12. <view :style="circle_style" class="circle"></view>
  13. <view :style="circle_style" class="circle2"></view>
  14. <div class="coupon_left">
  15. <div class="box_left">¥{{item.money}}</div>
  16. <div class="box_right">
  17. <div>{{item.type}}</div>
  18. <div>{{item.usemoney}}</div>
  19. </div>
  20. </div>
  21. <view class="coupon_right" @click="receive(item.batch_num)">领取</view>
  22. </view>
  23. </view>
  24. <view v-if="show==2" class="box2">
  25. <view class="coupon2" v-for="(item, index) in list" :key="item.id">
  26. <view class="coupon2_left">
  27. <div class="box2_top">¥{{item.money}}</div>
  28. <div class="box2_bottom">
  29. <div>{{item.type}}</div>
  30. </div>
  31. </view>
  32. <view class="coupon2_right" @click="receive(item.batch_num)">领取</view>
  33. </view>
  34. </view>
  35. <view class="box3" v-if="show==3">
  36. <view class="coupon3" v-for="(item, index) in list" :key="item.id">
  37. <div class="price">¥{{item.money}}</div>
  38. <div class="discount">{{item.type}}</div>
  39. <div class="mall">{{item.usemoney}}</div>
  40. <view class="receive" @click="receive(item.batch_num)">领取</view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import mallApi from '@/api/mall/index.js'
  48. export default {
  49. props: ['styles', 'datas'],
  50. data() {
  51. let siteinfo = getApp().globalData.siteinfo;
  52. return {
  53. settingFile: siteinfo,
  54. emptyImage: siteinfo.root_img + '/static/app/image.png',
  55. }
  56. },
  57. computed: {
  58. /** 副标题内容 */
  59. title() {
  60. return this.datas.title || '优惠券';
  61. },
  62. img_style2() {
  63. return `
  64. width:15px;
  65. height:15px;
  66. margin:auto;
  67. `;
  68. },
  69. // 副标题栏样式
  70. title_style() {
  71. const {
  72. text_size,
  73. text_color,
  74. } = this.datas;
  75. return `
  76. font-size: ${text_size}px;
  77. color: ${text_color};
  78. `;
  79. },
  80. // 排列样式
  81. show() {
  82. const {
  83. button_number
  84. } = this.datas
  85. return button_number
  86. },
  87. /** 样式 */
  88. wrapper_style() {
  89. if (this.datas) {
  90. const {
  91. padding_top,
  92. padding_bottom,
  93. padding_left,
  94. padding_right,
  95. bg_color
  96. } = this.datas;
  97. return `
  98. padding-top: ${padding_top}px;
  99. padding-bottom: ${padding_bottom}px;
  100. padding-left: ${padding_left}px;
  101. padding-right: ${padding_right}px;
  102. background-color:${bg_color};
  103. `;
  104. }
  105. },
  106. coupon() {
  107. return `
  108. display: flex;
  109. justify-content: space-between;
  110. align-items: center;
  111. width:100%;
  112. margin:auto;
  113. margin-bottom:10px;
  114. border-radius: 10px;
  115. `
  116. },
  117. img_style() {
  118. const {
  119. picture_border,
  120. } = this.datas;
  121. return `
  122. border-radius: ${picture_border}px;
  123. `;
  124. },
  125. circle_style() {
  126. const {
  127. bg_color
  128. } = this.datas
  129. return `
  130. background-color:${bg_color};
  131. `;
  132. },
  133. /** 标题 */
  134. list() {
  135. return this.datas.goods;
  136. },
  137. },
  138. methods: {
  139. more() {
  140. uni.navigateTo({
  141. url: '/pagesB/pages/getcoupon/getcoupon'
  142. })
  143. },
  144. receive(batch_num) {
  145. let that = this
  146. let params = {
  147. batch_num: batch_num
  148. }
  149. mallApi.getcoupon(params).then(res => {
  150. if (res.status === 200) {
  151. that.$api.msg(res.msg)
  152. } else {
  153. that.$api.msg(res.msg)
  154. }
  155. })
  156. }
  157. }
  158. };
  159. </script>
  160. <style lang="less" scoped>
  161. .component-wrapper {
  162. .morebox {
  163. display: flex;
  164. justify-content: space-between;
  165. align-items: center;
  166. margin-bottom: 15px;
  167. .title2 {
  168. font-size: 28rpx;
  169. display: flex;
  170. color: #949494;
  171. align-items: center;
  172. }
  173. }
  174. .box1 {
  175. display: flex;
  176. flex-wrap: wrap;
  177. justify-content: space-around;
  178. .coupon {
  179. color: #fff;
  180. height: 80px;
  181. position: relative;
  182. .circle {
  183. height: 26px;
  184. width: 26px;
  185. border-radius: 13px;
  186. position: absolute;
  187. top: -13px;
  188. right: 26.5%;
  189. background-color: #fff;
  190. }
  191. .circle2 {
  192. height: 26px;
  193. width: 26px;
  194. border-radius: 13px;
  195. position: absolute;
  196. bottom: -13px;
  197. right: 26.5%;
  198. background-color: #fff;
  199. }
  200. .coupon_left {
  201. background-image: linear-gradient(#BD8AFF, #5053FF);
  202. height: 100%;
  203. width: 70%;
  204. display: flex;
  205. justify-content: space-around;
  206. align-items: center;
  207. border-radius: 10px;
  208. .box_left {
  209. width: 30%;
  210. text-align: center;
  211. line-height: 80px;
  212. font-size: 27px;
  213. }
  214. .box_right {
  215. border-right: 2px dashed #fff;
  216. height: 50px;
  217. line-height: 25px;
  218. width: 70%;
  219. text-align: left;
  220. font-size: 13px;
  221. }
  222. }
  223. .coupon_right {
  224. background-image: linear-gradient(#BD8AFF, #5053FF);
  225. border-radius: 10px;
  226. width: 30%;
  227. height: 80px;
  228. line-height: 80px;
  229. text-align: center;
  230. font-size: 14px;
  231. }
  232. }
  233. }
  234. .box2 {
  235. display: flex;
  236. flex-wrap: wrap;
  237. width: 100%;
  238. .coupon2 {
  239. width: 45%;
  240. height: 90px;
  241. margin: 0 2.5%;
  242. margin-bottom: 15px;
  243. border-radius: 15px;
  244. background-image: linear-gradient(#BD8AFF, #5053FF);
  245. color: #fff;
  246. display: flex;
  247. align-items: center;
  248. .coupon2_left {
  249. width: 80%;
  250. text-align: center;
  251. .box2_top {
  252. font-size: 27px;
  253. margin-bottom: 5px;
  254. }
  255. }
  256. .coupon2_right {
  257. width: 20%;
  258. padding: 10px;
  259. font-size: 17px;
  260. writing-mode: lr-tb;
  261. text-align: center;
  262. }
  263. }
  264. }
  265. .box3 {
  266. display: flex;
  267. flex-wrap: wrap;
  268. width: 100%;
  269. .coupon3 {
  270. color: #fff;
  271. background-image: linear-gradient(#BD8AFF, #5053FF);
  272. width: 31.3%;
  273. margin: 0 1%;
  274. margin-bottom: 15px;
  275. padding: 15px 0;
  276. font-weight: lighter;
  277. border-radius: 15px;
  278. text-align: center;
  279. .price {
  280. font-size: 25px;
  281. margin-bottom: 10px;
  282. font-weight: lighter;
  283. }
  284. .discount {
  285. font-size: 15px;
  286. margin-bottom: 10px;
  287. }
  288. .mall {
  289. width: 100%;
  290. font-size: 13px;
  291. margin-bottom: 10px;
  292. }
  293. .receive {
  294. height: 25px;
  295. width: 60px;
  296. line-height: 25px;
  297. background-color: aliceblue;
  298. color: #1889f6;
  299. display: inline-block;
  300. border-radius: 15px;
  301. margin-top: 10px;
  302. }
  303. }
  304. }
  305. }
  306. </style>