chooseCoupons.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view >
  3. <ujp-navbar title="我的优惠券"><view class="exchange oldTextjp2" oldstyle="font-size: 16px;" @click="toConversion">兑换</view></ujp-navbar>
  4. <u-alert-tips size="12" :show-icon="true" type="warning"
  5. description="同类型优惠券只显示一张"></u-alert-tips>
  6. <view class="list-item"
  7. v-for="(item,index) in myCouponList"
  8. :style="item.chooseStatus == '0' ? 'opacity: 0.5':'' "
  9. @click="ckselectObj(item)"
  10. :key="item.id">
  11. <view
  12. :style="item.chooseStatus == '0' ? 'background-color:#9F9F9F':'' "
  13. class="voucher" v-if="item.classify == '1'">优惠券</view>
  14. <view
  15. :style="item.chooseStatus == '0' ? 'background-color:#9F9F9F':'' "
  16. class="voucher" v-if="item.classify == '2'">折扣卷</view>
  17. <view class="checked" v-if="selectObj.id==item.id">
  18. <img src="../../../static/img/选中.png" alt="">
  19. </view>
  20. <view class="item-left">
  21. <view class="title oldTextjp" oldstyle="font-size: 18px;">
  22. {{item.couponName}}
  23. </view>
  24. <view class="useful-life oldTextjp2" oldstyle="font-size: 16px;">
  25. 有效期至{{item.endDate&&item.endDate.slice(0,10)}}{{" "}}
  26. <span class="item-left-explain" @click.stop="gotoUrl('pages/user/coupon/couponDetails?id=' + item.id)">使用说明</span>
  27. </view>
  28. </view>
  29. <view class="item-right">
  30. <view class="price"
  31. :style="item.chooseStatus == '0' ? 'color:#666':'' "
  32. v-if="item.classify == '1'">{{item.value}}元</view>
  33. <view class="price2"
  34. :style="item.chooseStatus == '0' ? 'color:#666':'' "
  35. v-if="item.classify == '2'">服务费{{item.value}}折</view>
  36. <view class="contidion oldTextjp2" oldstyle="font-size: 16px;">
  37. {{item.threshold == 0 ? '无门槛' : '满'+item.threshold+'元可用'}}
  38. </view>
  39. </view>
  40. </view>
  41. <u-divider v-if="myCouponList.length > 0" style="margin-top: 10px;background-color: #F2F4F4;">已经到底了</u-divider>
  42. <view v-if="myCouponList.length > 0" style="padding-bottom: 80px;" ></view>
  43. <view class="carNone" v-if="myCouponList.length == 0">
  44. <img src="static/img/暂无数据-缺省页.png" alt="">
  45. <p>暂无优惠券</p>
  46. </view>
  47. <view class="bottom">
  48. <view class="text">
  49. <view class="num">
  50. <view class="price" v-if="selectObj.classify == '1'">抵扣{{selectObj.value}}元</view>
  51. <view class="price" v-if="selectObj.classify == '2'">服务费{{selectObj.value}}折</view>
  52. </view>
  53. </view>
  54. <u-button
  55. :style="selectObj.id ?'' : 'background-color:#9F9F9F'"
  56. @click="submitBtn"
  57. class="confirm" >
  58. <span>确定</span>
  59. </u-button>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. //import * as userApi from '@/apis/user.js'
  65. import * as userApi from '@/apis/chargeProcess.js'
  66. export default{
  67. data(){
  68. return{
  69. selectObj:{},
  70. amount:0,
  71. uuid:0,
  72. myCouponList: [],
  73. pageIndex: 1,
  74. recordsTotal: 0,
  75. stationId:"",
  76. }
  77. },
  78. onReachBottom() {
  79. if (this.myCouponList.length < this.recordsTotal) {
  80. this.myLoadmore();
  81. }
  82. },
  83. onLoad(op) {
  84. if(op.uuid){
  85. this.amount=op.amount
  86. this.uuid=op.uuid
  87. this.stationId=op.stationId;
  88. }
  89. },
  90. onShow() {
  91. this.getCouponList();
  92. },
  93. methods:{
  94. submitBtn(){
  95. if(this.selectObj.id){
  96. this.carhelp.set("chooseCoupons",{
  97. uuid:this.uuid,
  98. selectObj:this.selectObj
  99. })
  100. uni.navigateBack({
  101. })
  102. }
  103. },
  104. ckselectObj(item){
  105. if(item.chooseStatus==1){
  106. this.selectObj=item;
  107. }else{
  108. uni.showToast({
  109. title:"不满足使用条件"
  110. })
  111. }
  112. },
  113. toConversion() {
  114. uni.navigateTo({
  115. url: '/pages/user/coupon/conversion'
  116. })
  117. },
  118. getCouponList(bl) {
  119. uni.showLoading({
  120. title: "加载中",
  121. mask: true,
  122. })
  123. if (bl) {
  124. this.myCouponList = [];
  125. this.pageIndex = 1;
  126. }
  127. userApi.useCoupon({
  128. amount:this.amount,
  129. stationId:this.stationId
  130. }).then((res) => {
  131. uni.hideLoading();
  132. this.myCouponList =res.data.userCouponList
  133. this.recordsTotal = res.data.recordsTotal;
  134. }).catch(error => {
  135. uni.showToast({
  136. title: error,
  137. icon: "none"
  138. })
  139. })
  140. },
  141. myLoadmore() {
  142. this.pageIndex += 1;
  143. this.getCouponList()
  144. },
  145. }
  146. }
  147. </script>
  148. <style lang="scss">
  149. .carNone{
  150. display: flex;
  151. flex-direction: column;
  152. justify-content: center;
  153. align-items: center;
  154. img{
  155. width: 100%;
  156. height: 100%;
  157. }
  158. p{
  159. margin-top: -60px;
  160. }
  161. }
  162. .exchange{
  163. margin-left: 85.3%;
  164. color: rgba(119, 119, 119, 100);
  165. font-size: 12px
  166. }
  167. .list-item{
  168. width: 91.4%;
  169. display: flex;
  170. justify-content: space-between;
  171. background-color: #fff;
  172. margin: 12px auto 0;
  173. border-radius: 8px;
  174. position: relative;
  175. .voucher{
  176. width: 60px;
  177. height: 20px;
  178. line-height: 20px;
  179. border-radius: 8px 0px 8px 0px;
  180. background-color: rgba(0, 185, 98, 100);
  181. color: rgba(255, 255, 255, 100);
  182. font-size: 12px;
  183. text-align: center;
  184. position: absolute;
  185. top: 0;
  186. left: 0;
  187. }
  188. .checked{
  189. width: 28px;
  190. height: 28px;
  191. position: absolute;
  192. top: 0;
  193. right: 0;
  194. img{
  195. width: 100%;
  196. height: 100%;
  197. }
  198. }
  199. .item-left{
  200. padding: 24px 0 20px 5px;
  201. .title{
  202. line-height: 25px;
  203. color: rgba(16, 16, 16, 100);
  204. font-size: 18px;
  205. font-weight: 600;
  206. }
  207. .useful-life{
  208. line-height: 22px;
  209. color: rgba(51, 51, 51, 100);
  210. font-size: 14px;
  211. margin-top: 1px;
  212. }
  213. .item-left-explain {
  214. color: rgba(0, 185, 98, 100);
  215. font-size: 14px;
  216. }
  217. }
  218. .item-right{
  219. padding: 19px 5px 18px 0;
  220. .price{
  221. height: 38px;
  222. color: rgba(0, 185, 98, 100);
  223. font-size: 32px;
  224. text-align: right;
  225. }
  226. .price2{
  227. height: 38px;
  228. color: rgba(0, 185, 98, 100);
  229. font-size: 20px;
  230. text-align: right;
  231. }
  232. .contidion{
  233. height: 22px;
  234. color: rgba(51, 51, 51, 100);
  235. font-size: 16px;
  236. text-align: right;
  237. margin-top: 4px;
  238. }
  239. }
  240. }
  241. .have-used{
  242. width: 54px;
  243. height: 54px;
  244. position: absolute;
  245. top: -12px;
  246. right: 0;
  247. img{
  248. width: 100%;
  249. height: 100%;
  250. }
  251. }
  252. .bottom{
  253. position: fixed;
  254. bottom: 0;
  255. right: 0;
  256. width: 100%;
  257. height: 64px;
  258. line-height: 64px;
  259. background-color: #fff;
  260. padding: 0 16px;
  261. display: flex;
  262. justify-content: space-between;
  263. .text{
  264. height: 20px;
  265. color: rgba(16, 16, 16, 100);
  266. font-size: 18px;
  267. display: flex;
  268. .num{
  269. color: orangered;
  270. font-size: 18px
  271. }
  272. }
  273. .confirm{
  274. width: 100px;
  275. height: 40px;
  276. border-radius: 50px;
  277. background-color: rgba(0, 185, 98, 100);
  278. color: rgba(255, 255, 255, 100);
  279. font-size: 18px;
  280. text-align: center;
  281. margin: auto 10px ;
  282. }
  283. }
  284. </style>