couponDetails.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. background-color: #FFFFFF;
  172. width: 100%;
  173. height: 210rpx;
  174. position: relative;
  175. display: flex;
  176. align-items: center;
  177. padding-right: 30rpx;
  178. box-sizing: border-box;
  179. overflow: hidden;
  180. }
  181. .tui-coupon-bg {
  182. width: 100%;
  183. height: 210rpx;
  184. position: absolute;
  185. left: 0;
  186. top: 0;
  187. z-index: 1;
  188. }
  189. .tui-coupon-sign {
  190. height: 110rpx;
  191. width: 110rpx;
  192. position: absolute;
  193. z-index: 9;
  194. top: -30rpx;
  195. right: 40rpx;
  196. }
  197. .tui-coupon-item-left {
  198. width: 218rpx;
  199. height: 210rpx;
  200. position: relative;
  201. z-index: 2;
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. flex-direction: column;
  206. flex-shrink: 0;
  207. }
  208. .tui-coupon-price-box {
  209. display: flex;
  210. color: #e41f19;
  211. align-items: flex-end;
  212. }
  213. .tui-coupon-price-sign {
  214. font-size: 30rpx;
  215. }
  216. .tui-coupon-price {
  217. font-size: 32rpx;
  218. line-height: 68rpx;
  219. font-weight: bold;
  220. }
  221. .tui-price-small {
  222. font-size: 58rpx !important;
  223. line-height: 56rpx !important;
  224. }
  225. .tui-coupon-intro {
  226. background: #f7f7f7;
  227. padding: 8rpx 10rpx;
  228. font-size: 26rpx;
  229. line-height: 26rpx;
  230. font-weight: 400;
  231. color: #666;
  232. margin-top: 18rpx;
  233. }
  234. .tui-coupon-item-right {
  235. flex: 1;
  236. height: 210rpx;
  237. position: relative;
  238. z-index: 2;
  239. display: flex;
  240. align-items: center;
  241. justify-content: space-between;
  242. padding-left: 24rpx;
  243. box-sizing: border-box;
  244. overflow: hidden;
  245. }
  246. .tui-coupon-content {
  247. width: 82%;
  248. display: flex;
  249. flex-direction: column;
  250. justify-content: center;
  251. }
  252. .tui-coupon-title-box {
  253. display: flex;
  254. align-items: center;
  255. }
  256. .tui-coupon-btn {
  257. padding: 6rpx;
  258. background: #ffebeb;
  259. color: #FF5C03;
  260. font-size: 25rpx;
  261. line-height: 25rpx;
  262. display: flex;
  263. align-items: center;
  264. justify-content: center;
  265. transform: scale(0.9);
  266. transform-origin: 0 center;
  267. border-radius: 4rpx;
  268. flex-shrink: 0;
  269. }
  270. .tui-color-grey {
  271. color: #888 !important;
  272. }
  273. .tui-bg-grey {
  274. background: #f0f0f0 !important;
  275. color: #888 !important;
  276. }
  277. .tui-coupon-title {
  278. width: 100%;
  279. font-size: 26rpx;
  280. color: #333;
  281. white-space: nowrap;
  282. overflow: hidden;
  283. text-overflow: ellipsis;
  284. }
  285. .tui-coupon-rule {
  286. padding-top: 52rpx;
  287. }
  288. .tui-rule-box {
  289. display: flex;
  290. align-items: center;
  291. transform: scale(0.8);
  292. transform-origin: 0 100%;
  293. }
  294. .tui-padding-btm {
  295. padding-bottom: 6rpx;
  296. }
  297. .tui-coupon-circle {
  298. width: 8rpx;
  299. height: 8rpx;
  300. background: rgb(160, 160, 160);
  301. border-radius: 50%;
  302. }
  303. .tui-coupon-text {
  304. font-size: 28rpx;
  305. line-height: 28rpx;
  306. font-weight: 400;
  307. color: #666;
  308. padding-left: 8rpx;
  309. white-space: nowrap;
  310. }
  311. .tui-top20 {
  312. margin-top: 20rpx;
  313. }
  314. .tui-coupon-title {
  315. font-size: 28rpx;
  316. line-height: 28rpx;
  317. }
  318. .tui-coupon-radio {
  319. transform: scale(0.7);
  320. transform-origin: 100% center;
  321. }
  322. .tui-btn-box {
  323. position: absolute;
  324. right: 20rpx;
  325. bottom: 40rpx;
  326. z-index: 10;
  327. .btn{
  328. width: 155upx;
  329. height: 64upx;
  330. line-height: 64upx;
  331. font-size: 26upx;
  332. font-family: PingFang SC;
  333. font-weight: 500;
  334. text-align: center;
  335. border-radius: 32upx;
  336. margin-left: 15upx;
  337. &.cancel{
  338. border: 1px solid #FF5C03;
  339. color: #FF5C03;
  340. }
  341. &.receive{
  342. background: #FF5C03;
  343. color: #FFFFFF;
  344. }
  345. }
  346. }
  347. </style>