active.vue 9.9 KB

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