couponDetails.vue 7.3 KB

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