couponDetails.vue 7.6 KB

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