couponDetails.vue 7.3 KB

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