couponDetails.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. <template>
  2. <view class="container">
  3. <view class="tui-coupon-list">
  4. <view class="tui-coupon-item tui-top20" >
  5. <image src="https://kntobs.jnmyunl.com/shop/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='isShare!=1' @click="showpop(item)">发送</view>
  32. <view class="btn cancel" v-if="item.receiveCount>0">已领取</view>
  33. <view class="btn cancel" v-else-if="item.receiveCount==item.totalCount" >已领完</view>
  34. <view class="btn receive" v-else @click="receive(item.id,index)">立即领取</view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- <view class="banner" @click="showImg()">
  39. <image class="img" src="https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20221116/99f6dedb47394b43adb61a1aa1b2e7e2.jpg"></image>
  40. </view> -->
  41. <!-- <view class="ad">
  42. <ad unit-id="adunit-4768dead82e0c4ff" ad-type="video" ad-theme="white"></ad>
  43. </view> -->
  44. <view>
  45. <u-popup :show="popshow" @close="close" :closeOnClickOverlay='true'>
  46. <view class="popbox">
  47. <view class="pop-tit">
  48. <view class="poptitle">选择用户</view>
  49. <u-icon name="close" size="24" @click="close"></u-icon>
  50. </view>
  51. <view class="popsh">
  52. <u-search :showAction="true" actionText="搜索" placeholder="输入手机号搜索"
  53. :animation="true" v-model="keyword" @search='searchkey(value)' @custom='searchkey(value)'></u-search>
  54. </view>
  55. <view class="poplist">
  56. <view class="list-box" v-for="(item,index) in phoneUser" :key="index">
  57. <view class="tit">{{item.name}}</view>
  58. <view class="send" @click="sendpop(item.id)">发送</view>
  59. </view>
  60. </view>
  61. </view>
  62. </u-popup>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import { getCouponIssueById, receive,sendCoupon,searchUser} from '@/api/coupon'
  68. import { mapGetters } from 'vuex';
  69. export default {
  70. name: 'getCoupon',
  71. props: {},
  72. data: function() {
  73. return {
  74. id:null,
  75. item:null,
  76. CompanyUserInfo:{},
  77. user:{},
  78. popshow:false,
  79. keyword:'',
  80. phoneUser:{},
  81. isShare: 0
  82. }
  83. },
  84. onLoad(options) {
  85. console.log(options.id)
  86. this.isShare = options.isShare || 0
  87. this.id=JSON.parse(options.id);
  88. this.CompanyUserInfo=uni.getStorageSync('CompanyUserInfo');
  89. if(this.isShare==1){
  90. uni.hideShareMenu()
  91. if(!this.utils.isLogin()) return
  92. }else{
  93. console.log(JSON.stringify(this.CompanyUserInfo))
  94. uni.showShareMenu()
  95. }
  96. this.getCouponIssueById();
  97. },
  98. //发送给朋友
  99. onShareAppMessage(res) {
  100. wx.updateShareMenu({
  101. isPrivateMessage: true
  102. })
  103. return {
  104. title: this.item.couponName,
  105. path: `/pages_company/couponDetails?isShare=1&id=${this.item.id}`,
  106. imageUrl:this.logoimg
  107. }
  108. },
  109. mounted: function() {
  110. },
  111. onShow() {
  112. this.CompanyUserInfo=uni.getStorageSync('CompanyUserInfo');
  113. this.user=uni.getStorageSync('userInfo');
  114. },
  115. computed: {
  116. ...mapGetters(['logoimg']),
  117. },
  118. watch: {
  119. logoimg: {
  120. immediate: true, // 页面一进入就检查一次
  121. handler(val) {
  122. return val
  123. }
  124. },
  125. },
  126. methods: {
  127. sendpop(id){
  128. this.sendCoupon(id)
  129. },
  130. sendCoupon(id){
  131. const data={
  132. id:this.item.id,
  133. companyUserId:this.CompanyUserInfo.userId,
  134. companyId:this.CompanyUserInfo.companyId,
  135. setSendUserId:this.user.userId,
  136. userId:id,
  137. companyUserToken:uni.getStorageSync('CompanyUserToken')
  138. }
  139. sendCoupon(data).then(res=>{
  140. if(res.code==200){
  141. uni.showToast({
  142. icon:'none',
  143. title: '发送成功!',
  144. });
  145. }else{
  146. uni.showToast({
  147. icon:'none',
  148. title: res.msg,
  149. });
  150. }
  151. })
  152. },
  153. searchkey(value){
  154. console.log(this.keyword);
  155. searchUser({value:this.keyword}).then(res=>{
  156. if(res.code==200){
  157. this.phoneUser=res.rows
  158. console.log(res)
  159. }else{
  160. uni.showToast({
  161. icon:'none',
  162. title: res.msg,
  163. });
  164. }
  165. })
  166. },
  167. close(){
  168. this.popshow=false
  169. },
  170. showpop(item){
  171. this.popshow=true
  172. this.detailsid=item
  173. console.log(item)
  174. },
  175. showImg() {
  176. var url=['https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20221116/99f6dedb47394b43adb61a1aa1b2e7e2.jpg']
  177. uni.previewImage({
  178. urls: url,
  179. current: url[0]
  180. });
  181. },
  182. getCouponIssueById: function() {
  183. let that = this
  184. var data={id:this.id}
  185. getCouponIssueById(data)
  186. .then(function(res) {
  187. that.item=res.data;
  188. })
  189. .catch(function(err) {
  190. uni.showToast({
  191. title: err.msg ,
  192. icon: 'none',
  193. duration: 2000,
  194. })
  195. })
  196. },
  197. receive: function() {
  198. if(this.utils.isLogin()){
  199. let that = this
  200. var data={id:this.item.id}
  201. receive(data)
  202. .then(function(res) {
  203. if(res.code==200){
  204. uni.showToast({
  205. title: '领取成功',
  206. icon: 'success',
  207. duration: 2000,
  208. })
  209. }
  210. else{
  211. uni.showToast({
  212. title: res.msg,
  213. duration: 2000,
  214. })
  215. }
  216. })
  217. .catch(function(err) {
  218. uni.showToast({
  219. title: err.msg ,
  220. icon: 'none',
  221. duration: 2000,
  222. })
  223. })
  224. }
  225. },
  226. },
  227. }
  228. </script>
  229. <style lang="less" scoped>
  230. .popbox{
  231. padding: 20rpx;
  232. height: 400rpx;
  233. .poplist{
  234. margin-top: 20rpx;
  235. .list-box{
  236. display: flex;
  237. justify-content: space-between;
  238. align-items: center;
  239. .tit{
  240. font-size:24rpx;
  241. color: #666;
  242. }
  243. .send{
  244. width: 122rpx;
  245. height: 50rpx;
  246. line-height: 50rpx;
  247. font-size: 26upx;
  248. font-family: PingFang SC;
  249. font-weight: 500;
  250. text-align: center;
  251. border-radius: 32upx;
  252. margin-left: 15upx;
  253. border: 1px solid #2BC7B9;
  254. color: #2BC7B9;
  255. }
  256. }
  257. }
  258. }
  259. .pop-tit{
  260. display: flex;
  261. padding: 20rpx;
  262. .poptitle{
  263. flex: 1;
  264. text-align: center;
  265. }
  266. }
  267. page {
  268. background-color: #f5f5f5;
  269. }
  270. .container {
  271. height: 100%;
  272. display: flex;
  273. flex-direction: column;
  274. }
  275. .tui-coupon-list {
  276. width: 100%;
  277. padding: 0 25rpx;
  278. box-sizing: border-box;
  279. }
  280. .tui-coupon-banner {
  281. width: 100%;
  282. }
  283. .tui-coupon-item {
  284. width: 100%;
  285. height: 210rpx;
  286. position: relative;
  287. display: flex;
  288. align-items: center;
  289. padding-right: 30rpx;
  290. box-sizing: border-box;
  291. overflow: hidden;
  292. }
  293. .tui-coupon-bg {
  294. width: 100%;
  295. height: 210rpx;
  296. position: absolute;
  297. left: 0;
  298. top: 0;
  299. z-index: 1;
  300. }
  301. .tui-coupon-sign {
  302. height: 110rpx;
  303. width: 110rpx;
  304. position: absolute;
  305. z-index: 9;
  306. top: -30rpx;
  307. right: 40rpx;
  308. }
  309. .tui-coupon-item-left {
  310. width: 218rpx;
  311. height: 210rpx;
  312. position: relative;
  313. z-index: 2;
  314. display: flex;
  315. align-items: center;
  316. justify-content: center;
  317. flex-direction: column;
  318. flex-shrink: 0;
  319. }
  320. .tui-coupon-price-box {
  321. display: flex;
  322. color: #e41f19;
  323. align-items: flex-end;
  324. }
  325. .tui-coupon-price-sign {
  326. font-size: 30rpx;
  327. }
  328. .tui-coupon-price {
  329. font-size: 70rpx;
  330. line-height: 68rpx;
  331. font-weight: bold;
  332. }
  333. .tui-price-small {
  334. font-size: 58rpx !important;
  335. line-height: 56rpx !important;
  336. }
  337. .tui-coupon-intro {
  338. background: #f7f7f7;
  339. padding: 8rpx 10rpx;
  340. font-size: 26rpx;
  341. line-height: 26rpx;
  342. font-weight: 400;
  343. color: #666;
  344. margin-top: 18rpx;
  345. }
  346. .tui-coupon-item-right {
  347. flex: 1;
  348. height: 210rpx;
  349. position: relative;
  350. z-index: 2;
  351. display: flex;
  352. align-items: center;
  353. justify-content: space-between;
  354. padding-left: 24rpx;
  355. box-sizing: border-box;
  356. overflow: hidden;
  357. }
  358. .tui-coupon-content {
  359. width: 82%;
  360. display: flex;
  361. flex-direction: column;
  362. justify-content: center;
  363. }
  364. .tui-coupon-title-box {
  365. display: flex;
  366. align-items: center;
  367. }
  368. .tui-coupon-btn {
  369. padding: 6rpx;
  370. background: #ffebeb;
  371. color: #e41f19;
  372. font-size: 25rpx;
  373. line-height: 25rpx;
  374. display: flex;
  375. align-items: center;
  376. justify-content: center;
  377. transform: scale(0.9);
  378. transform-origin: 0 center;
  379. border-radius: 4rpx;
  380. flex-shrink: 0;
  381. }
  382. .tui-color-grey {
  383. color: #888 !important;
  384. }
  385. .tui-bg-grey {
  386. background: #f0f0f0 !important;
  387. color: #888 !important;
  388. }
  389. .tui-coupon-title {
  390. width: 100%;
  391. font-size: 26rpx;
  392. color: #333;
  393. white-space: nowrap;
  394. overflow: hidden;
  395. text-overflow: ellipsis;
  396. }
  397. .tui-coupon-rule {
  398. padding-top: 52rpx;
  399. }
  400. .tui-rule-box {
  401. display: flex;
  402. align-items: center;
  403. transform: scale(0.8);
  404. transform-origin: 0 100%;
  405. }
  406. .tui-padding-btm {
  407. padding-bottom: 6rpx;
  408. }
  409. .tui-coupon-circle {
  410. width: 8rpx;
  411. height: 8rpx;
  412. background: rgb(160, 160, 160);
  413. border-radius: 50%;
  414. }
  415. .tui-coupon-text {
  416. font-size: 28rpx;
  417. line-height: 28rpx;
  418. font-weight: 400;
  419. color: #666;
  420. padding-left: 8rpx;
  421. white-space: nowrap;
  422. }
  423. .tui-top20 {
  424. margin-top: 20rpx;
  425. }
  426. .tui-coupon-title {
  427. font-size: 28rpx;
  428. line-height: 28rpx;
  429. }
  430. .tui-coupon-radio {
  431. transform: scale(0.7);
  432. transform-origin: 100% center;
  433. }
  434. .tui-btn-box {
  435. position: absolute;
  436. right: 20rpx;
  437. bottom: 40rpx;
  438. z-index: 10;
  439. .btn{
  440. width: 155upx;
  441. height: 64upx;
  442. line-height: 64upx;
  443. font-size: 26upx;
  444. font-family: PingFang SC;
  445. font-weight: 500;
  446. text-align: center;
  447. border-radius: 32upx;
  448. margin-left: 15upx;
  449. &.cancel{
  450. border: 1px solid #2BC7B9;
  451. color: #2BC7B9;
  452. margin-bottom: 8rpx;
  453. }
  454. &.receive{
  455. background: #2BC7B9;
  456. color: #FFFFFF;
  457. }
  458. }
  459. }
  460. .banner{
  461. margin: 25rpx;
  462. .img{
  463. height: 700rpx;
  464. width: 100%;
  465. }
  466. }
  467. .ad{
  468. margin: 0rpx 0rpx 60rpx;
  469. }
  470. </style>