active.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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. // #ifdef MP-WEIXIN
  87. //分享按钮
  88. uni.showShareMenu({
  89. withShareTicket: true,
  90. menus: ['shareAppMessage', 'shareTimeline']
  91. })
  92. // #endif
  93. },
  94. onShareAppMessage(obj) {
  95. return {
  96. title: this.activeInfo.name,
  97. path: '/pages/coupon/active?id='+this.requestParam.id,
  98. }
  99. },
  100. onShow() {
  101. // 登录提示
  102. if( !this.$checkAccess.alterLogin() ) return ;
  103. // 如果存在产品ID的话
  104. if( this.requestParam.id > 0) {
  105. // 请求详情
  106. this.$http.request('api/coupon_active/get_detail',this.requestParam).then((re)=>{
  107. // 成功渲染数据
  108. if( re.code == 'success' ) {
  109. // 刷新数据
  110. this.activeInfo = re.data;
  111. // 列表大于2.显示
  112. if( re.data.product_list.length <= 2 ) this.show_more_product = true;
  113. }else{
  114. uni.showModal({
  115. content:re.msg,
  116. showCancel:false,
  117. })
  118. }
  119. });
  120. }else{
  121. uni.showModal({
  122. content:"未知的活动ID",
  123. showCancel:false,
  124. })
  125. }
  126. },
  127. methods: {
  128. toUse(item){
  129. // 没有范围
  130. if( item.type_id == 2 ){
  131. uni.switchTab({url:"/pages/index/index"});
  132. return;
  133. }
  134. // 只有一个商品,直接跳转到对应商品
  135. if( item.product_scope.length == 1 ){
  136. uni.navigateTo({
  137. url:"/pages/product/index?product_id="+item.product_scope[0]
  138. })
  139. return;
  140. }
  141. // 没有范围
  142. if( item.product_scope.length > 1 ){
  143. uni.navigateTo({
  144. url:"/pages/coupon/product?coupon_id="+item.coupon_id
  145. });
  146. return;
  147. }
  148. },
  149. getCoupon(index){
  150. // 获取对应的数据
  151. let couponId = this.activeInfo.coupon_list[index].coupon_id;
  152. // 如果不能参与
  153. if( !this.activeInfo.allow_join ) {
  154. uni.showModal({
  155. content:"暂不可参与活动",
  156. showCancel:false,
  157. })
  158. return;
  159. }
  160. // 如果存在优惠券
  161. if( couponId > 0) {
  162. // 请求详情
  163. this.$http.request('api/custom_coupon/get_coupon',{coupon_id:couponId}).then((re)=>{
  164. // 成功渲染数据
  165. if( re.code == 'success' ) {
  166. this.activeInfo.coupon_list[index].is_have = 1;
  167. }else{
  168. uni.showModal({
  169. content:re.msg,
  170. showCancel:false,
  171. })
  172. }
  173. });
  174. }else{
  175. uni.showModal({
  176. content:"请选择要领取的优惠券",
  177. showCancel:false,
  178. })
  179. }
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="less">
  185. .banner_box{
  186. width: 750rpx;
  187. height: 240rpx;
  188. display: block;
  189. overflow: hidden;
  190. margin: 0rpx auto;
  191. .banner_img{
  192. width: 750rpx;
  193. height: 240rpx;
  194. }
  195. }
  196. .active_info{
  197. width: 750rpx;
  198. display: block;
  199. overflow: hidden;
  200. margin: 0rpx auto;
  201. padding: 10rpx 35rpx;
  202. background-color: #FFFFFF;
  203. .active_name{
  204. display: block;
  205. height: 60rpx;
  206. font-size: 36rpx;
  207. font-weight: bold;
  208. line-height: 60rpx;
  209. overflow: hidden;
  210. white-space: nowrap;
  211. text-overflow: ellipsis;
  212. }
  213. .active_time{
  214. display: block;
  215. height: 40rpx;
  216. font-size: 26rpx;
  217. line-height: 40rpx;
  218. overflow: hidden;
  219. white-space: nowrap;
  220. text-overflow: ellipsis;
  221. }
  222. .active_citys{
  223. display: block;
  224. max-height: 80rpx;
  225. font-size: 26rpx;
  226. line-height: 40rpx;
  227. overflow: hidden;
  228. white-space: nowrap;
  229. text-overflow: ellipsis;
  230. }
  231. }
  232. .active_coupon{
  233. display: block;
  234. overflow: hidden;
  235. margin-top: 20rpx;
  236. padding: 0rpx 35rpx;
  237. .active_subtitle{
  238. display: block;
  239. height: 80rpx;
  240. overflow: hidden;
  241. font-size: 32rpx;
  242. font-weight: bold;
  243. line-height: 80rpx;
  244. }
  245. .coupon_list{
  246. display: block;
  247. overflow: hidden;
  248. .coupon_item{
  249. display: block;
  250. height: 140rpx;
  251. overflow: hidden;
  252. padding: 10rpx 25rpx;
  253. border-radius: 15rpx;
  254. margin-bottom: 10rpx;
  255. background-color: #FFFFFF;
  256. .left_box{
  257. float: left;
  258. width: 400rpx;
  259. height: 140rpx;
  260. display: block;
  261. .rebate{
  262. color: #E03519;
  263. height: 60rpx;
  264. font-size: 36rpx;
  265. line-height: 60rpx;
  266. font-weight: bold;
  267. }
  268. .std_pay{
  269. color: #666666;
  270. height: 40rpx;
  271. font-size: 24rpx;
  272. line-height: 40rpx;
  273. }
  274. .coupon_exp{
  275. color: #666666;
  276. height: 40rpx;
  277. font-size: 24rpx;
  278. line-height: 40rpx;
  279. }
  280. }
  281. .right_box{
  282. float: right;
  283. width: 160rpx;
  284. height: 60rpx;
  285. display: block;
  286. margin-top: 40rpx;
  287. .get_btn{
  288. display: block;
  289. width: 160rpx;
  290. height: 60rpx;
  291. color: #FFFFFF;
  292. font-size: 26rpx;
  293. line-height: 60rpx;
  294. text-align: center;
  295. padding: 0rpx 0rpx;
  296. border-radius: 10rpx;
  297. background-color: #E03519;
  298. }
  299. }
  300. }
  301. }
  302. }
  303. .active_product{
  304. display: block;
  305. overflow: hidden;
  306. margin-top: 10rpx;
  307. padding: 0rpx 35rpx;
  308. .active_subtitle{
  309. display: block;
  310. height: 80rpx;
  311. overflow: hidden;
  312. font-size: 32rpx;
  313. font-weight: bold;
  314. line-height: 80rpx;
  315. }
  316. .product_list{
  317. display: block;
  318. height: 520rpx;
  319. overflow: hidden;
  320. .product_item{
  321. float: left;
  322. width: 320rpx;
  323. height: 480rpx;
  324. display: block;
  325. overflow: hidden;
  326. margin-top: 20rpx;
  327. margin-right: 40rpx;
  328. background-color: #FFFFFF;
  329. border-radius: 20rpx;
  330. .product_image{
  331. width: 320rpx;
  332. height: 320rpx;
  333. }
  334. .product_name{
  335. height: 80rpx;
  336. font-size: 30rpx;
  337. line-height: 40rpx;
  338. overflow: hidden;
  339. margin: 0rpx 0rpx;
  340. padding: 0rpx 10rpx;
  341. text-overflow: ellipsis;
  342. }
  343. .stock_price{
  344. color: #dddddd;
  345. font-size: 20rpx;
  346. overflow: hidden;
  347. line-height: 30rpx;
  348. padding: 0rpx 10rpx;
  349. .product_price{
  350. float: left;
  351. color: red;
  352. font-size: 30rpx;
  353. line-height: 60rpx;
  354. .product_market{
  355. font-size: 24rpx;
  356. color: #999999;
  357. line-height: 30rpx;
  358. vertical-align: top;
  359. text-decoration: line-through;
  360. }
  361. }
  362. .product_stock{
  363. float: right;
  364. font-size: 20rpx;
  365. line-height: 60rpx;
  366. }
  367. }
  368. }
  369. .product_item:nth-child(even){
  370. margin-right: 0rpx;
  371. }
  372. }
  373. .product_list.more{
  374. height: auto !important;
  375. }
  376. .more_product{
  377. z-index: 8;
  378. left: 0rpx;
  379. top: -10rpx;
  380. height: 40rpx;
  381. display: block;
  382. font-size: 20rpx;
  383. line-height: 40rpx;
  384. text-align: center;
  385. position: relative;
  386. border-radius: 5rpx;
  387. background-color: rgba(0, 0, 0, 0.1);
  388. }
  389. }
  390. .active_rule{
  391. display: block;
  392. overflow: hidden;
  393. margin-top: 10rpx;
  394. padding: 0rpx 35rpx;
  395. margin-bottom: 160rpx;
  396. .active_subtitle{
  397. display: block;
  398. height: 80rpx;
  399. overflow: hidden;
  400. font-size: 32rpx;
  401. font-weight: bold;
  402. line-height: 80rpx;
  403. }
  404. .active_rule_info{
  405. display: block;
  406. overflow: hidden;
  407. font-size: 24rpx;
  408. min-height: 500rpx;
  409. line-height: 40rpx;
  410. border-radius: 10rpx;
  411. padding: 20rpx 20rpx;
  412. box-sizing: border-box;
  413. background-color: #FFFFFF;
  414. .rich_text{
  415. white-space: break-spaces;
  416. }
  417. }
  418. }
  419. </style>