couponDetails.vue 10.0 KB

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