couponDetails.vue 10 KB

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