verification.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="verification">
  3. <view :isBack="true" titleTintColor="#fff" search class='headerNav'>
  4. <text></text>
  5. <image class="uni_btnImage" src="../../static/img/cm.png" @click="scanCode"></image>
  6. </view>
  7. <view class="">
  8. <view class="letter" v-for="l in list">
  9. <view class="header">
  10. <view class="left tico">
  11. 订单号: {{ l.id }}
  12. </view>
  13. <view class="right">
  14. 待核销
  15. </view>
  16. </view>
  17. <view class="middle">
  18. <image src="../../static/img/verification.png" mode=""></image>
  19. <view class="inf">
  20. <text class="name"><b>{{ l.ticket_name }}</b></text><br>
  21. <text class="time tico">{{ getTime(l.add_time) }}</text>
  22. </view>
  23. </view>
  24. <view class="footer">
  25. <view class="about tico">
  26. 当前已核销{{ l.num }}次,还剩{{ l.all_num - l.num }}次
  27. </view>
  28. <view class="button" @click="navTo(l.ticket_code)">
  29. 出示核销
  30. </view>
  31. </view>
  32. </view>
  33. <view class="jz">
  34. -------{{ loadingType=='loadmore'?'加载中':'加载完成'}}-------
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import weichatObj from "@/plugin/jweixin-module/index.js";
  41. import { sanCode } from '../../utils/wxAuthorized.js'
  42. import { getTicket,check } from '../../api/apply.js'
  43. // import { mapState } from 'vuex';
  44. export default {
  45. data() {
  46. return {
  47. page: 1,
  48. limit: 10,
  49. loadingType: 'loadmore',
  50. list: [],
  51. }
  52. },
  53. mounted() {
  54. this.init()
  55. },
  56. methods: {
  57. // 初始化数据
  58. init() {
  59. const that = this// 获取项目对象
  60. if (that.loadingType === 'loading') {
  61. //防止重复加载
  62. return;
  63. }
  64. if (that.loadingType === 'nomore') {
  65. //防止重复加载
  66. return;
  67. }
  68. // 修改当前对象状态为加载中
  69. that.loadingType = 'loading';
  70. const data = {page: this.page,limit: this.limit}
  71. console.log(data);
  72. getTicket(data)
  73. .then(e => {
  74. const data = e.data.list
  75. that.list = data
  76. that.page++;
  77. if (that.limit == data.length) {
  78. //判断是否还有数据, 有改为 more, 没有改为noMore
  79. that.loadingType = 'loadmore';
  80. return;
  81. } else {
  82. //判断是否还有数据, 有改为 more, 没有改为noMore
  83. that.loadingType = 'nomore';
  84. }
  85. }).catch(e => {
  86. that.loadingType = 'loadmore';
  87. console.log(e);
  88. });
  89. },// 页面下拉到底部加载
  90. onReachBottom() {
  91. this.ticketList()
  92. console.log("dddd")
  93. },
  94. ticketList() {
  95. const that = this// 获取项目对象
  96. if (that.loadingType === 'loading') {
  97. //防止重复加载
  98. return;
  99. }
  100. if (that.loadingType === 'nomore') {
  101. //防止重复加载
  102. return;
  103. }
  104. // 修改当前对象状态为加载中
  105. that.loadingType = 'loading';
  106. const data = {page: this.page+1,limit: this.limit}
  107. console.log(data);
  108. getTicket(data)
  109. .then(e => {
  110. const data = e.data.list;
  111. that.list = data
  112. that.page++;
  113. if (that.limit == data.length) {
  114. //判断是否还有数据, 有改为 more, 没有改为noMore
  115. that.loadingType = 'loadmore';
  116. return;
  117. } else {
  118. //判断是否还有数据, 有改为 more, 没有改为noMore
  119. that.loadingType = 'nomore';
  120. }
  121. }).catch(e => {
  122. that.loadingType = 'loadmore';
  123. console.log(e);
  124. });
  125. },
  126. navTo(id) {
  127. uni.navigateTo({
  128. url: '/pages/apply/qrcode?id='+id
  129. })
  130. },
  131. // 扫一扫
  132. scanCode() {
  133. console.log("===");
  134. // const weichatObj = this.$store.state.weichatObj
  135. console.log(weichatObj)
  136. weichatObj.scanQRCode({
  137. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  138. scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
  139. success: function(res) {
  140. console.log(res.resultStr);
  141. // obj.orderVerific(res.resultStr); // 当needResult 为 1 时,扫码返回的结果
  142. check({code: res.resultStr}).then(res => {
  143. console.log(res);
  144. this.scanCodeSuccessTo()
  145. })
  146. }
  147. });
  148. },
  149. // 核销成功
  150. scanCodeSuccessTo() {
  151. const that = this
  152. uni.showToast({
  153. title: '核销成功',
  154. duration: 2000,
  155. position: 'top'
  156. });
  157. },
  158. // 时间戳转换成时间
  159. getTime(time) {
  160. const num =13 - (time+'').length;
  161. let l = 1;//倍数
  162. for (let i = 0; i < num; i++) {
  163. l+='0';
  164. }
  165. // 重新解析为数字
  166. l = parseInt(l)
  167. const date = new Date(parseInt(time) * l);
  168. const year = date.getFullYear();
  169. const mon = date.getMonth() + 1;
  170. const day = date.getDate();
  171. const hours = date.getHours();
  172. const minu = date.getMinutes();
  173. const sec = date.getSeconds();
  174. return year + '-' + mon + '-' + day + ' ' + hours + ':' + minu + ':' + sec;
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .tico {
  181. color: #999;
  182. }
  183. .nav {
  184. display: flex;
  185. justify-content: space-around;
  186. background-color: #fff;
  187. .isclick {
  188. color: #3b66f5;
  189. border-bottom: solid 5rpx #3b66f5;
  190. }
  191. .item {
  192. padding: 20rpx;
  193. }
  194. }
  195. .letter {
  196. margin: 30rpx;
  197. padding: 20rpx;
  198. background-color: #fff;
  199. border-radius: 10rpx;
  200. box-shadow:2rpx 2rpx 20rpx #dedede;
  201. .header {
  202. display: flex;
  203. justify-content: space-between;
  204. .left {
  205. color: #999;
  206. }
  207. .right {
  208. color: red;
  209. }
  210. }
  211. .middle {
  212. display: flex;
  213. margin: 20rpx 0;
  214. image {
  215. width: 80rpx;
  216. height: 80rpx;
  217. margin: auto 0;
  218. }
  219. .inf {
  220. margin: auto 20rpx;
  221. text {
  222. padding: 20rpx 0;
  223. }
  224. .name {
  225. font-size: 30rpx;
  226. }
  227. }
  228. }
  229. .footer {
  230. display: flex;
  231. justify-content: space-between;
  232. .button {
  233. background-color: #3b66f5;
  234. color: #fff;
  235. padding: 6rpx 20rpx;
  236. border-radius: 50rpx;
  237. }
  238. }
  239. }
  240. .jz {
  241. text-align: center;
  242. color: #999;
  243. }
  244. .headerNav {
  245. background-color: #fff;
  246. padding: 20rpx;
  247. display: flex;
  248. justify-content: space-between;
  249. }
  250. .uni_btnImage {
  251. width: 50rpx;
  252. height: 50rpx;
  253. }
  254. </style>