active.vue 12 KB

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