couponGoods.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view class="container">
  3. <view class="cate-nav">
  4. <view class="name">优惠券:{{couponName}}</view>
  5. <view class="desc" v-if="coupon.voucherType==3">商品兑换件数:{{coupon.goodsNum}} 件</view>
  6. <view class="desc" v-if="coupon.voucherType!=3">
  7. {{coupon.discount}}{{coupon.voucherType==1?'元':'折'}} | 满{{coupon.min}}元可用
  8. </view>
  9. </view>
  10. <view class="cate-item">
  11. <view class="b">
  12. <navigator :class="'item ' + ((iindex + 1) % 2 == 0 ? 'item-b' : '')" :url="'/pages/goods/goods?id=' + iitem.id" v-for="(iitem, iindex) in goodsList" :key="iindex">
  13. <image class="img" :src="iitem.picUrl" background-size="cover"></image>
  14. <view style="display: flex; margin-top: 20rpx; height: 71rpx">
  15. <text class="name">{{ iitem.name }}</text>
  16. </view>
  17. <view class="price">
  18. <view v-if="iitem.activited" class="retailPrice">
  19. <text class="price-unit">¥</text>
  20. {{ iitem.activityPrice }}
  21. </view>
  22. <view v-else class="retailPrice">
  23. <text class="price-unit">¥</text>
  24. {{ iitem.retailPrice }}
  25. </view>
  26. <view v-if="iitem.activited || iitem.counterPrice != iitem.retailPrice" class="counterPrice">原价¥{{ iitem.counterPrice }}</view>
  27. </view>
  28. </navigator>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. var util = require('../../../utils/util.js');
  35. var api = require('../../../config/api.js');
  36. var user = require('../../../utils/user.js');
  37. export default {
  38. data() {
  39. return {
  40. couponName: '',
  41. goodsList: [],
  42. couponId: 0,
  43. coupon:{},
  44. addressInfo: {},
  45. code: '',
  46. iindex: 0,
  47. iitem: {
  48. id: '',
  49. picUrl: '',
  50. name: '',
  51. activited: '',
  52. counterPrice: '',
  53. retailPrice: ''
  54. }
  55. };
  56. }
  57. /**
  58. * 生命周期函数--监听页面加载
  59. */,
  60. onLoad: function (options) {
  61. console.log("options",options);
  62. if (options.id) {
  63. this.setData({
  64. couponId: options.id
  65. });
  66. }
  67. this.getGoodsList();
  68. },
  69. /**
  70. * 生命周期函数--监听页面初次渲染完成
  71. */
  72. onReady: function () {},
  73. /**
  74. * 生命周期函数--监听页面显示
  75. */
  76. onShow: function () {},
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide: function () {},
  81. /**
  82. * 生命周期函数--监听页面卸载
  83. */
  84. onUnload: function () {},
  85. /**
  86. * 页面相关事件处理函数--监听用户下拉动作
  87. */
  88. onPullDownRefresh: function () {},
  89. /**
  90. * 页面上拉触底事件的处理函数
  91. */
  92. onReachBottom: function () {},
  93. /**
  94. * 用户点击右上角分享
  95. */
  96. onShareAppMessage: function () {},
  97. methods: {
  98. getGoodsList: function () {
  99. var that = this;
  100. util.request(api.GoodsCoupon, {
  101. id: that.couponId,
  102. }).then(function (res) {
  103. that.setData({
  104. goodsList: res.data.list,
  105. couponName: res.data.couponName,
  106. coupon:res.data.coupon
  107. });
  108. //如果只有一个商品 直接跳转商详页
  109. if (res.data.list.length == 1) {
  110. uni.redirectTo({
  111. url: '/pages/goods/goods?id=' + res.data.list[0].id
  112. });
  113. }
  114. else if(res.data.list.length == 0){//表示全场通用,直接跳转到商品列表页
  115. console.log("全场通用",res.data.list)
  116. uni.navigateTo({
  117. url: '/pages/index/index'
  118. });
  119. }
  120. });
  121. }
  122. }
  123. };
  124. </script>
  125. <style>
  126. .container {
  127. background: #f9f9f9;
  128. }
  129. .counterPrice {
  130. text-decoration: line-through;
  131. font-size: 24rpx;
  132. margin: 0 0 0 20rpx;
  133. color: #c7c7c7;
  134. }
  135. .cate-nav {
  136. text-align: center;
  137. z-index: 1000;
  138. padding: 20rpx 0;
  139. font-size: 32rpx;
  140. border-bottom: 2rpx solid #e4e4e4;
  141. }
  142. .price-unit {
  143. font-size: 23rpx;
  144. font-weight: 400;
  145. color: #202020;
  146. }
  147. .cate-nav-body {
  148. height: 84rpx;
  149. white-space: nowrap;
  150. background: #fff;
  151. border-top: 1px solid rgba(0, 0, 0, 0.15);
  152. overflow: hidden;
  153. }
  154. .cate-nav .item {
  155. display: inline-block;
  156. height: 84rpx;
  157. min-width: 130rpx;
  158. padding: 0 15rpx;
  159. }
  160. .cate-nav .item .name {
  161. display: block;
  162. height: 84rpx;
  163. padding: 0 20rpx;
  164. line-height: 84rpx;
  165. color: #333;
  166. font-size: 30rpx;
  167. width: auto;
  168. }
  169. .cate-nav .item.active .name {
  170. color: #09afff;
  171. border-bottom: 2px solid #09afff;
  172. }
  173. .cate-item {
  174. height: auto;
  175. overflow: hidden;
  176. }
  177. .cate-item .h {
  178. height: 145rpx;
  179. width: 750rpx;
  180. display: flex;
  181. flex-direction: column;
  182. align-items: center;
  183. justify-content: center;
  184. }
  185. .cate-item .h .name {
  186. display: block;
  187. height: 35rpx;
  188. margin-bottom: 18rpx;
  189. font-size: 30rpx;
  190. color: #333;
  191. }
  192. .cate-item .h .desc {
  193. display: block;
  194. height: 24rpx;
  195. font-size: 24rpx;
  196. color: #999;
  197. }
  198. .cate-item .b {
  199. width: 750rpx;
  200. padding: 0 6.25rpx;
  201. height: auto;
  202. overflow: hidden;
  203. }
  204. .cate-item .b .item {
  205. float: left;
  206. background: #fff;
  207. width: 342rpx;
  208. height: auto;
  209. overflow: hidden;
  210. padding: 15rpx;
  211. border-radius: 15rpx;
  212. margin: 16.5rpx 16.5rpx 8.5rpx 16.5rpx;
  213. }
  214. .cate-item .b .item-b {
  215. margin-left: 6.25rpx;
  216. }
  217. .cate-item .item .img {
  218. width: 300rpx;
  219. height: 300rpx;
  220. display: block;
  221. margin: auto;
  222. border-radius: 18rpx;
  223. }
  224. .cate-item .b .item .mark {
  225. width: 122rpx;
  226. height: 100rpx;
  227. margin-top: -20rpx;
  228. margin-left: 0rpx;
  229. }
  230. .cate-item .item .name {
  231. display: block;
  232. width: 365.625rpx;
  233. margin: 0 0 5rpx 0;
  234. overflow: hidden;
  235. padding: 0 20rpx;
  236. font-size: 26rpx;
  237. color: #1c1c1c;
  238. line-height: 1.3em;
  239. padding-left: 0rpx;
  240. text-align: left;
  241. }
  242. .cate-item .item .brand {
  243. display: block;
  244. width: 365.625rpx;
  245. height: 22rpx;
  246. font-size: 22rpx;
  247. color: #ab956d;
  248. margin-top: 10rpx;
  249. margin-left: 22rpx;
  250. }
  251. .cate-item .item .price {
  252. height: 40rpx;
  253. display: flex;
  254. /* margin-top: 20rpx; */
  255. align-items: flex-end;
  256. }
  257. .retailPrice {
  258. font-size: 30rpx;
  259. height: 30rpx;
  260. line-height: 30rpx;
  261. }
  262. .memberPrice {
  263. font-size: 22rpx;
  264. color: #dd483e;
  265. margin: 0 10rpx 0 20rpx;
  266. }
  267. .member-price-tag {
  268. width: 88rpx;
  269. height: 26rpx;
  270. line-height: 26rpx;
  271. background: url('https://mall.zhaijieshi.cc/file/jzmall/weixin/member/member-price-bg.png') no-repeat center center;
  272. background-size: 100% 100%;
  273. color: #5e3a11;
  274. font-size: 16rpx;
  275. padding: 0 8rpx 0 0;
  276. text-align: right;
  277. margin: 0 0 6rpx 0;
  278. }
  279. </style>