active.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <view>
  3. <view class="banner_box">
  4. <image class="banner_img" :src="activeInfo.banner_img" ></image>
  5. </view>
  6. <view class="active_info">
  7. <view class="active_name">{{activeInfo.name}}</view>
  8. <view class="active_time">活动时间:{{activeInfo.start_date}} ~ {{activeInfo.end_date}}</view>
  9. <view class="active_citys">活动范围:{{activeInfo.city_ids}}</view>
  10. </view>
  11. <view class="active_coupon">
  12. <view class="active_subtitle">优惠券</view>
  13. <view class="coupon_list">
  14. <view class="coupon_item" v-for="(item,index) in activeInfo.coupon_list" :key="index">
  15. <view class="left_box">
  16. <view class="rebate" v-if="item.rebate_type == 1" > ¥{{item.rebate}}</view>
  17. <view class="rebate" v-if="item.rebate_type == 2" > 打 {{item.rebate}} 折</view>
  18. <view class="rebate" v-if="item.rebate_type == 3" > 赠 <text v-if="item.rebate_scope.length">{{item.rebate_scope[0].product_name}}</text> </view>
  19. <view class="std_pay">满 ¥{{item.std_pay}} 可用</view>
  20. <view class="coupon_exp">有效期:{{item.exp_time}}</view>
  21. </view>
  22. <view class="right_box">
  23. <button class="get_btn" v-if="item.is_have == 0" @click="getCoupon(index)">立即领取</button>
  24. <button class="get_btn" v-if="item.is_have == 1" @click="toUse(item)">去使用</button>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="active_product">
  30. <view class="active_subtitle">活动商品</view>
  31. <view class="product_list" :class="show_more_product?'more':''">
  32. <view class="product_item" v-for="(item,index) in activeInfo.product_list" :key="index" >
  33. <image class="product_image" :src="item.thumb" mode=""></image>
  34. <view class="product_name"><text>{{item.product_name}}</text></view>
  35. <view class="stock_price">
  36. <view class="product_price" >
  37. <text >¥ {{item.price}} </text>
  38. </view>
  39. <view class="product_stock">剩{{item.stock}}个</view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="more_product" v-if="!show_more_product" @click.stop="show_more_product = true">
  44. <uni-icons type="down" size="20" ></uni-icons>
  45. </view>
  46. </view>
  47. <view class="active_rule">
  48. <view class="active_subtitle">活动规则</view>
  49. <view class="active_rule_info">
  50. <rich-text class="rich_text" :nodes="activeInfo.active_rule"></rich-text>
  51. </view>
  52. </view>
  53. <view class="" style="height: 10rpx;"></view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. // 是否显示更多的产品
  61. show_more_product:false,
  62. // 活动信息
  63. activeInfo:{
  64. id:0,
  65. name:"",
  66. banner_img:"",
  67. active_rule:"",
  68. status:0,
  69. start_time:0,
  70. end_time:0,
  71. city_ids:"",
  72. allow_join:0,
  73. start_date:"",
  74. end_date:"",
  75. coupon_list:[],
  76. product_list:[],
  77. },
  78. // 请求参数
  79. requestParam:{
  80. id:0
  81. },
  82. }
  83. },
  84. onLoad(param) {
  85. this.requestParam.id = param.id;
  86. },
  87. onShow() {
  88. // 登录提示
  89. if( !this.$checkAccess.alterLogin() ) return ;
  90. // 如果存在产品ID的话
  91. if( this.requestParam.id > 0) {
  92. // 请求详情
  93. this.$http.request('api/coupon_active/get_detail',this.requestParam).then((re)=>{
  94. // 成功渲染数据
  95. if( re.code == 'success' ) {
  96. // 刷新数据
  97. this.activeInfo = re.data;
  98. // 列表大于2.显示
  99. if( re.data.product_list.length <= 2 ) this.show_more_product = true;
  100. }else{
  101. uni.showModal({
  102. content:re.msg,
  103. showCancel:false,
  104. })
  105. }
  106. });
  107. }else{
  108. uni.showModal({
  109. content:"未知的活动ID",
  110. showCancel:false,
  111. })
  112. }
  113. },
  114. methods: {
  115. toUse(item){
  116. // 没有范围
  117. if( item.type_id == 2 ){
  118. uni.switchTab({url:"/pages/index/index"});
  119. return;
  120. }
  121. // 只有一个商品,直接跳转到对应商品
  122. if( item.product_scope.length == 1 ){
  123. uni.navigateTo({
  124. url:"/pages/product/index?product_id="+item.product_scope[0]
  125. })
  126. return;
  127. }
  128. // 没有范围
  129. if( item.product_scope.length > 1 ){
  130. uni.navigateTo({
  131. url:"/pages/coupon/product?coupon_id="+item.coupon_id
  132. });
  133. return;
  134. }
  135. },
  136. getCoupon(index){
  137. // 获取对应的数据
  138. let couponId = this.activeInfo.coupon_list[index].coupon_id;
  139. // 如果不能参与
  140. if( !this.activeInfo.allow_join ) {
  141. uni.showModal({
  142. content:"暂不可参与活动",
  143. showCancel:false,
  144. })
  145. return;
  146. }
  147. // 如果存在优惠券
  148. if( couponId > 0) {
  149. // 请求详情
  150. this.$http.request('api/custom_coupon/get_coupon',{coupon_id:couponId}).then((re)=>{
  151. // 成功渲染数据
  152. if( re.code == 'success' ) {
  153. this.activeInfo.coupon_list[index].is_have = 1;
  154. }else{
  155. uni.showModal({
  156. content:re.msg,
  157. showCancel:false,
  158. })
  159. }
  160. });
  161. }else{
  162. uni.showModal({
  163. content:"请选择要领取的优惠券",
  164. showCancel:false,
  165. })
  166. }
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="less">
  172. .banner_box{
  173. width: 750rpx;
  174. height: 240rpx;
  175. display: block;
  176. overflow: hidden;
  177. margin: 0rpx auto;
  178. .banner_img{
  179. width: 750rpx;
  180. height: 240rpx;
  181. }
  182. }
  183. .active_info{
  184. width: 750rpx;
  185. display: block;
  186. overflow: hidden;
  187. margin: 0rpx auto;
  188. padding: 10rpx 35rpx;
  189. background-color: #FFFFFF;
  190. .active_name{
  191. display: block;
  192. height: 60rpx;
  193. font-size: 36rpx;
  194. font-weight: bold;
  195. line-height: 60rpx;
  196. overflow: hidden;
  197. white-space: nowrap;
  198. text-overflow: ellipsis;
  199. }
  200. .active_time{
  201. display: block;
  202. height: 40rpx;
  203. font-size: 26rpx;
  204. line-height: 40rpx;
  205. overflow: hidden;
  206. white-space: nowrap;
  207. text-overflow: ellipsis;
  208. }
  209. .active_citys{
  210. display: block;
  211. max-height: 80rpx;
  212. font-size: 26rpx;
  213. line-height: 40rpx;
  214. overflow: hidden;
  215. white-space: nowrap;
  216. text-overflow: ellipsis;
  217. }
  218. }
  219. .active_coupon{
  220. display: block;
  221. overflow: hidden;
  222. margin-top: 20rpx;
  223. padding: 0rpx 35rpx;
  224. .active_subtitle{
  225. display: block;
  226. height: 80rpx;
  227. overflow: hidden;
  228. font-size: 32rpx;
  229. font-weight: bold;
  230. line-height: 80rpx;
  231. }
  232. .coupon_list{
  233. display: block;
  234. overflow: hidden;
  235. .coupon_item{
  236. display: block;
  237. height: 140rpx;
  238. overflow: hidden;
  239. padding: 10rpx 25rpx;
  240. border-radius: 15rpx;
  241. margin-bottom: 10rpx;
  242. background-color: #FFFFFF;
  243. .left_box{
  244. float: left;
  245. width: 400rpx;
  246. height: 140rpx;
  247. display: block;
  248. .rebate{
  249. color: #E03519;
  250. height: 60rpx;
  251. font-size: 36rpx;
  252. line-height: 60rpx;
  253. font-weight: bold;
  254. }
  255. .std_pay{
  256. color: #666666;
  257. height: 40rpx;
  258. font-size: 24rpx;
  259. line-height: 40rpx;
  260. }
  261. .coupon_exp{
  262. color: #666666;
  263. height: 40rpx;
  264. font-size: 24rpx;
  265. line-height: 40rpx;
  266. }
  267. }
  268. .right_box{
  269. float: right;
  270. width: 160rpx;
  271. height: 60rpx;
  272. display: block;
  273. margin-top: 40rpx;
  274. .get_btn{
  275. display: block;
  276. width: 160rpx;
  277. height: 60rpx;
  278. color: #FFFFFF;
  279. font-size: 26rpx;
  280. line-height: 60rpx;
  281. text-align: center;
  282. padding: 0rpx 0rpx;
  283. border-radius: 10rpx;
  284. background-color: #E03519;
  285. }
  286. }
  287. }
  288. }
  289. }
  290. .active_product{
  291. display: block;
  292. overflow: hidden;
  293. margin-top: 10rpx;
  294. padding: 0rpx 35rpx;
  295. .active_subtitle{
  296. display: block;
  297. height: 80rpx;
  298. overflow: hidden;
  299. font-size: 32rpx;
  300. font-weight: bold;
  301. line-height: 80rpx;
  302. }
  303. .product_list{
  304. display: block;
  305. height: 520rpx;
  306. overflow: hidden;
  307. .product_item{
  308. float: left;
  309. width: 320rpx;
  310. height: 480rpx;
  311. display: block;
  312. overflow: hidden;
  313. margin-top: 20rpx;
  314. margin-right: 40rpx;
  315. background-color: #FFFFFF;
  316. border-radius: 20rpx;
  317. .product_image{
  318. width: 320rpx;
  319. height: 320rpx;
  320. }
  321. .product_name{
  322. height: 80rpx;
  323. font-size: 30rpx;
  324. line-height: 40rpx;
  325. overflow: hidden;
  326. margin: 0rpx 0rpx;
  327. padding: 0rpx 10rpx;
  328. text-overflow: ellipsis;
  329. }
  330. .stock_price{
  331. color: #dddddd;
  332. font-size: 20rpx;
  333. overflow: hidden;
  334. line-height: 30rpx;
  335. padding: 0rpx 10rpx;
  336. .product_price{
  337. float: left;
  338. color: red;
  339. font-size: 30rpx;
  340. line-height: 60rpx;
  341. .product_market{
  342. font-size: 24rpx;
  343. color: #999999;
  344. line-height: 30rpx;
  345. vertical-align: top;
  346. text-decoration: line-through;
  347. }
  348. }
  349. .product_stock{
  350. float: right;
  351. font-size: 20rpx;
  352. line-height: 60rpx;
  353. }
  354. }
  355. }
  356. .product_item:nth-child(even){
  357. margin-right: 0rpx;
  358. }
  359. }
  360. .product_list.more{
  361. height: auto !important;
  362. }
  363. .more_product{
  364. z-index: 8;
  365. left: 0rpx;
  366. top: -10rpx;
  367. height: 40rpx;
  368. display: block;
  369. font-size: 20rpx;
  370. line-height: 40rpx;
  371. text-align: center;
  372. position: relative;
  373. border-radius: 5rpx;
  374. background-color: rgba(0, 0, 0, 0.1);
  375. }
  376. }
  377. .active_rule{
  378. display: block;
  379. overflow: hidden;
  380. margin-top: 10rpx;
  381. padding: 0rpx 35rpx;
  382. margin-bottom: 160rpx;
  383. .active_subtitle{
  384. display: block;
  385. height: 80rpx;
  386. overflow: hidden;
  387. font-size: 32rpx;
  388. font-weight: bold;
  389. line-height: 80rpx;
  390. }
  391. .active_rule_info{
  392. display: block;
  393. overflow: hidden;
  394. font-size: 24rpx;
  395. min-height: 500rpx;
  396. line-height: 40rpx;
  397. border-radius: 10rpx;
  398. padding: 20rpx 20rpx;
  399. box-sizing: border-box;
  400. background-color: #FFFFFF;
  401. .rich_text{
  402. white-space: break-spaces;
  403. }
  404. }
  405. }
  406. </style>