couponDetails.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <view class="container">
  3. <view class="tui-coupon-list">
  4. <view class="tui-coupon-item tui-top20" >
  5. <image src="/static/images/bg_coupon_3x.png" class="tui-coupon-bg" mode="widthFix"></image>
  6. <view class="tui-coupon-item-left">
  7. <view class="tui-coupon-price-box" >
  8. <view class="tui-coupon-price-sign">¥</view>
  9. <view class="tui-coupon-price" :class="{ 'tui-price-small': false }">{{ item.couponPrice }}</view>
  10. </view>
  11. <view class="tui-coupon-intro">满{{ item.useMinPrice }}元可用</view>
  12. </view>
  13. <view class="tui-coupon-item-right">
  14. <view class="tui-coupon-content">
  15. <view class="tui-coupon-title-box">
  16. <view class="tui-coupon-title">{{ item.couponName }}</view>
  17. </view>
  18. <view class="tui-coupon-rule">
  19. <view class="tui-rule-box tui-padding-btm">
  20. <view class="tui-coupon-circle"></view>
  21. <view class="tui-coupon-text">不可叠加使用</view>
  22. </view>
  23. <view class="tui-rule-box">
  24. <view class="tui-coupon-circle"></view>
  25. <view class="tui-coupon-text">{{ item.limitTime }} 到期</view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="tui-btn-box" v-if="type==2">
  31. <view class="btn cancel" v-if="item.receiveCount>0" >已领取</view>
  32. <view class="btn cancel" v-else-if="item.receiveCount==item.totalCount" >已领完</view>
  33. <view class="btn receive" v-else @click="receive(item.id,index)">立即领取</view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="ad">
  38. <ad unit-id="adunit-4768dead82e0c4ff" ad-type="video" ad-theme="white"></ad>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import { getCouponIssueById, companyReceive } from '@/api/coupon'
  44. export default {
  45. name: 'getCoupon',
  46. props: {},
  47. data: function() {
  48. return {
  49. id:null,
  50. item:null,
  51. code:null,
  52. type:0,
  53. }
  54. },
  55. onLoad(options) {
  56. //获取券CODE
  57. console.log(options.id)
  58. console.log(options.code)
  59. this.type=options.type;
  60. this.id=JSON.parse(options.id);
  61. if(!this.$isEmpty(options.code)){
  62. this.code=options.code;
  63. }
  64. uni.showShareMenu({
  65. withShareTicket:true,
  66. //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  67. menus:["shareAppMessage"] //不设置默认发送给朋友
  68. })
  69. this.getCouponIssueById();
  70. },
  71. //发送给朋友
  72. onShareAppMessage(res) {
  73. return {
  74. title: this.item.couponName,
  75. path: `/pages_company/couponDetails?id=${this.item.id}&type=2&code=${this.code}`
  76. }
  77. },
  78. mounted: function() {
  79. },
  80. onShow() {
  81. },
  82. methods: {
  83. showImg() {
  84. var url=['https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20221116/99f6dedb47394b43adb61a1aa1b2e7e2.jpg']
  85. uni.previewImage({
  86. urls: url,
  87. current: url[0]
  88. });
  89. },
  90. getCouponIssueById: function() {
  91. let that = this
  92. var data={id:this.id}
  93. getCouponIssueById(data)
  94. .then(function(res) {
  95. that.item=res.data;
  96. console.log(that.code)
  97. if(that.$isEmpty(that.code)){
  98. that.code=res.code;
  99. }
  100. console.log(that.code)
  101. })
  102. .catch(function(err) {
  103. uni.showToast({
  104. title: err.msg ,
  105. icon: 'none',
  106. duration: 2000,
  107. })
  108. })
  109. },
  110. receive: function() {
  111. if(this.$isLogin()){
  112. let that = this
  113. var data={
  114. id:this.item.id,
  115. code:this.code
  116. }
  117. companyReceive(data)
  118. .then(function(res) {
  119. if(res.code==200){
  120. uni.showToast({
  121. title: '领取成功',
  122. icon: 'success',
  123. duration: 2000,
  124. })
  125. }
  126. else{
  127. uni.showToast({
  128. title: res.msg,
  129. duration: 2000,
  130. })
  131. }
  132. })
  133. .catch(function(err) {
  134. uni.showToast({
  135. title: err.msg ,
  136. icon: 'none',
  137. duration: 2000,
  138. })
  139. })
  140. }
  141. },
  142. },
  143. }
  144. </script>
  145. <style lang="less" scoped>
  146. page {
  147. background-color: #f5f5f5;
  148. }
  149. .container {
  150. height: 100%;
  151. display: flex;
  152. flex-direction: column;
  153. }
  154. .tui-coupon-list {
  155. width: 100%;
  156. padding: 0 25rpx;
  157. box-sizing: border-box;
  158. }
  159. .tui-coupon-banner {
  160. width: 100%;
  161. }
  162. .tui-coupon-item {
  163. width: 100%;
  164. height: 210rpx;
  165. position: relative;
  166. display: flex;
  167. align-items: center;
  168. padding-right: 30rpx;
  169. box-sizing: border-box;
  170. overflow: hidden;
  171. }
  172. .tui-coupon-bg {
  173. width: 100%;
  174. height: 210rpx;
  175. position: absolute;
  176. left: 0;
  177. top: 0;
  178. z-index: 1;
  179. }
  180. .tui-coupon-sign {
  181. height: 110rpx;
  182. width: 110rpx;
  183. position: absolute;
  184. z-index: 9;
  185. top: -30rpx;
  186. right: 40rpx;
  187. }
  188. .tui-coupon-item-left {
  189. width: 218rpx;
  190. height: 210rpx;
  191. position: relative;
  192. z-index: 2;
  193. display: flex;
  194. align-items: center;
  195. justify-content: center;
  196. flex-direction: column;
  197. flex-shrink: 0;
  198. }
  199. .tui-coupon-price-box {
  200. display: flex;
  201. color: #e41f19;
  202. align-items: flex-end;
  203. }
  204. .tui-coupon-price-sign {
  205. font-size: 30rpx;
  206. }
  207. .tui-coupon-price {
  208. font-size: 32rpx;
  209. line-height: 68rpx;
  210. font-weight: bold;
  211. }
  212. .tui-price-small {
  213. font-size: 58rpx !important;
  214. line-height: 56rpx !important;
  215. }
  216. .tui-coupon-intro {
  217. background: #f7f7f7;
  218. padding: 8rpx 10rpx;
  219. font-size: 26rpx;
  220. line-height: 26rpx;
  221. font-weight: 400;
  222. color: #666;
  223. margin-top: 18rpx;
  224. }
  225. .tui-coupon-item-right {
  226. flex: 1;
  227. height: 210rpx;
  228. position: relative;
  229. z-index: 2;
  230. display: flex;
  231. align-items: center;
  232. justify-content: space-between;
  233. padding-left: 24rpx;
  234. box-sizing: border-box;
  235. overflow: hidden;
  236. }
  237. .tui-coupon-content {
  238. width: 82%;
  239. display: flex;
  240. flex-direction: column;
  241. justify-content: center;
  242. }
  243. .tui-coupon-title-box {
  244. display: flex;
  245. align-items: center;
  246. }
  247. .tui-coupon-btn {
  248. padding: 6rpx;
  249. background: #ffebeb;
  250. color: #e41f19;
  251. font-size: 25rpx;
  252. line-height: 25rpx;
  253. display: flex;
  254. align-items: center;
  255. justify-content: center;
  256. transform: scale(0.9);
  257. transform-origin: 0 center;
  258. border-radius: 4rpx;
  259. flex-shrink: 0;
  260. }
  261. .tui-color-grey {
  262. color: #888 !important;
  263. }
  264. .tui-bg-grey {
  265. background: #f0f0f0 !important;
  266. color: #888 !important;
  267. }
  268. .tui-coupon-title {
  269. width: 100%;
  270. font-size: 26rpx;
  271. color: #333;
  272. white-space: nowrap;
  273. overflow: hidden;
  274. text-overflow: ellipsis;
  275. }
  276. .tui-coupon-rule {
  277. padding-top: 52rpx;
  278. }
  279. .tui-rule-box {
  280. display: flex;
  281. align-items: center;
  282. transform: scale(0.8);
  283. transform-origin: 0 100%;
  284. }
  285. .tui-padding-btm {
  286. padding-bottom: 6rpx;
  287. }
  288. .tui-coupon-circle {
  289. width: 8rpx;
  290. height: 8rpx;
  291. background: rgb(160, 160, 160);
  292. border-radius: 50%;
  293. }
  294. .tui-coupon-text {
  295. font-size: 28rpx;
  296. line-height: 28rpx;
  297. font-weight: 400;
  298. color: #666;
  299. padding-left: 8rpx;
  300. white-space: nowrap;
  301. }
  302. .tui-top20 {
  303. margin-top: 20rpx;
  304. }
  305. .tui-coupon-title {
  306. font-size: 28rpx;
  307. line-height: 28rpx;
  308. }
  309. .tui-coupon-radio {
  310. transform: scale(0.7);
  311. transform-origin: 100% center;
  312. }
  313. .tui-btn-box {
  314. position: absolute;
  315. right: 20rpx;
  316. bottom: 40rpx;
  317. z-index: 10;
  318. .btn{
  319. width: 155upx;
  320. height: 64upx;
  321. line-height: 64upx;
  322. font-size: 26upx;
  323. font-family: PingFang SC;
  324. font-weight: 500;
  325. text-align: center;
  326. border-radius: 32upx;
  327. margin-left: 15upx;
  328. &.cancel{
  329. border: 1px solid red;
  330. color: red;
  331. }
  332. &.receive{
  333. background: red;
  334. color: #FFFFFF;
  335. }
  336. }
  337. }
  338. .banner{
  339. margin: 25rpx;
  340. .img{
  341. height: 700rpx;
  342. width: 100%;
  343. }
  344. }
  345. .ad{
  346. margin: 0rpx 0rpx 60rpx;
  347. }
  348. </style>