couponDetails.vue 10.0 KB

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