secondCard.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view :style="[mainStyle]">
  3. <view class="tab bgfff dflex">
  4. <view :class="'li ' + (currentTab == 1 ? 'active' : '')" @tap="tab(1)">未使用({{total}})</view>
  5. <view :class="'li ' + (currentTab == 2 ? 'active' : '')" @tap="tab(2)">已使用({{useTotal}})</view>
  6. <view :class="'li ' + (currentTab == 3 ? 'active' : '')" @tap="tab(3)">已失效({{loseTotal}})</view>
  7. </view>
  8. <!-- 卡 -->
  9. <view class="list" v-if="pageList&&pageList.length>0">
  10. <view :class="'li' + (currentTab == 1 ? '' : ' hui')" v-for="(item, index) in pageList" :key="index">
  11. <view class="info dflex" @tap="currentTab == 1 ? jumpUrl('/service/secondCardDetail/secondCardDetail?orderProductId=' + item.orderProductId) : ''">
  12. <view class="left-pic">
  13. <image :src="item.productPic"></image>
  14. </view>
  15. <view class="flex">
  16. <view class="title">{{item.proudctName}}</view>
  17. <view class="time" v-if="item.expireTime">{{item.expireTime}}</view>
  18. </view>
  19. <view class="info-r">
  20. <view class="money">{{item.quantity}}<text>次</text></view>
  21. <view class="man">免费使用</view>
  22. </view>
  23. </view>
  24. <view class="li-bot dflex">
  25. <view class="check dflex flex" @click.stop="checks(item,index)">查看详情
  26. <image v-if="!item.isShow" src="../static/images/bico.png" ></image>
  27. <image v-else src="../static/images/bico_h.png" ></image>
  28. </view>
  29. <!-- <image src="../static/images/ma_dark.png" class="ma" @click="createCode(item)"></image> -->
  30. <view class="yong dflex" @tap="currentTab == 1 ? jumpUrl('/service/secondCardDetail/secondCardDetail?orderProductId=' + item.orderProductId) : ''" v-if="currentTab == 1">去使用</view>
  31. <view class="yi" v-else>
  32. <image src="../static/images/yishiyong.png" class="yipic" v-if="currentTab == 2"></image>
  33. <image src="../static/images/yishixiao.png" class="yipic" v-else></image>
  34. </view>
  35. </view>
  36. <view class="infos" v-if="item.isShow">
  37. <view>使用范围:仅限“{{item.proudctName}}”使用{{item.quantity}}次</view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="nodata" v-else>
  42. <image :src="picUrlss+'empty_dd.png'"></image>
  43. <text>暂无次卡</text>
  44. </view>
  45. <view class="ceng" v-if="isShowCard" @click="hideCardPop"></view>
  46. <view class="qrcode" v-if="isShowCard">
  47. <view class="qr-code ddflex">
  48. <u-qrcode ref="qrcode" canvas-id="qrcode" :value="currentCard.code" size="200"></u-qrcode>
  49. </view>
  50. <view class="code ddflex"><text>{{currentCard.code}}</text><view class="copy" @click="copyCode">复制</view></view>
  51. <!-- <view @click="scanCode">扫码</view> -->
  52. <image src="../../static/pages/images/close2.png" class="close" @click="hideCardPop"></image>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. const req = require("../../utils/request.js");
  58. const api = require("../../utils/api.js");
  59. const app = getApp();
  60. export default {
  61. data() {
  62. return {
  63. mainStyle: app.globalData.mainStyle,
  64. picUrlss: req.public.picUrls,
  65. currentTab: 1,
  66. form:{
  67. page: 1,
  68. limit: 10
  69. },
  70. pageList:[],
  71. isLoad: true,
  72. total: 0,
  73. currentCard: {},
  74. isShowCard: false,
  75. useTotal: 0,
  76. loseTotal: 0
  77. }
  78. },
  79. components: {},
  80. props: {},
  81. onLoad() {
  82. this.getPageList()
  83. this.getCount(1,suc=>{
  84. this.total = suc;
  85. });
  86. this.getCount(2,suc=>{
  87. this.useTotal = suc;
  88. });
  89. this.getCount(3,suc=>{
  90. this.loseTotal = suc;
  91. });
  92. },
  93. onReachBottom() {
  94. this.form.page++
  95. this.getPageList()
  96. },
  97. methods:{
  98. getCount(state,success){
  99. req.getRequest('/api/v3/secondary/card/count',{state: state},data=>{//状态 1、未使用 2、已使用 3、已失效
  100. success.call(this,data)
  101. })
  102. },
  103. tab(index) {
  104. if (this.currentTab === index) return false;
  105. this.currentTab = index
  106. this.form.page = 1
  107. this.isLoad = true
  108. this.getPageList()
  109. },
  110. getPageList(){
  111. if (!this.isLoad) return false;
  112. this.isLoad = false;
  113. let that = this;
  114. let form = that.form
  115. form.state = that.currentTab
  116. if(form.page == 1){
  117. uni.showLoading()
  118. }
  119. req.getRequest(api.card_polymerization,form,data=>{
  120. if (data.list && data.list.length >= 10) that.isLoad = true;
  121. if (that.form.page > 1) data.list = that.pageList.concat(data.list);
  122. data.list.map(it=>{
  123. it.isShow = false;
  124. return it;
  125. })
  126. that.pageList = data.list
  127. uni.hideLoading();
  128. })
  129. },
  130. checks(item,index){
  131. let pageList = this.pageList;
  132. if(pageList[index].isShow){
  133. pageList[index].isShow = false;
  134. this.pageList=JSON.parse(JSON.stringify(pageList))
  135. }else{
  136. pageList.map((it,dx)=>{
  137. if(dx==index) it.isShow = true;
  138. else it.isShow = false;
  139. return it;
  140. });
  141. this.pageList=JSON.parse(JSON.stringify(pageList))
  142. }
  143. },
  144. createCode(item){
  145. this.currentCard = item;
  146. this.isShowCard = true
  147. },
  148. hideCardPop(){
  149. this.isShowCard = false
  150. },
  151. copyCode(){
  152. uni.setClipboardData({
  153. data: this.currentCard.code,
  154. success() {
  155. req.msg('复制成功')
  156. }
  157. })
  158. },
  159. jumpUrl(url) {
  160. uni.navigateTo({
  161. url: url
  162. })
  163. },
  164. scanCode(){
  165. uni.scanCode({
  166. success: function (res) {
  167. console.log('条码类型:' + res.scanType);
  168. console.log('条码内容:' + res.result);
  169. uni.navigateTo({
  170. url: '/mine/secondCard/secondCard?code=' + res.result
  171. })
  172. }
  173. })
  174. }
  175. }
  176. }
  177. </script>
  178. <style>
  179. @import "./secondCard.css"
  180. </style>