couponDetails.vue 9.9 KB

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