couponDetails.vue 10 KB

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