entity.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view class="content">
  3. <scroll-view scroll-y="true" :style="{'height': height}" class="stk-list-wrap">
  4. <view class="" style="height: 20rpx;"></view>
  5. <view class="stk-wrap" v-for="item in list">
  6. <image src="https://zccy.liuniu946.com/static/img/stk.png" mode="" class="stk-bg"></image>
  7. <view class="stk-name">
  8. <image src="/static/icon/stk-logo.png" mode=""></image>
  9. {{item.name}}
  10. </view>
  11. <view class="stk-info flex">
  12. <view class="info-no">
  13. 卡号:<text>{{item.code}}</text>
  14. </view>
  15. <view class="info-state">
  16. {{type==1?'已发放':'已核销'}}
  17. </view>
  18. </view>
  19. </view>
  20. <uni-load-more :status="loadingType"></uni-load-more>
  21. <view class="btm-btn">
  22. <view class="btn" @click="opentc">
  23. {{type==1?'实体卡发放':'实体卡核销'}}
  24. </view>
  25. </view>
  26. </scroll-view>
  27. <uni-popup ref="popupStk" type="center">
  28. <view class="stk-tc">
  29. <image src="https://zccy.liuniu946.com/static/img/gift-bg.png" mode="" class="gift-bg"></image>
  30. <view class="gift-bg-mb"></view>
  31. <image src="https://zccy.liuniu946.com/static/img/stk-gift.png" mode="" class="gift"></image>
  32. <view class="" style="height: 145rpx;">
  33. </view>
  34. <view class="tc-tit">
  35. {{type==1?'实体卡发放':'实体卡核销'}}
  36. </view>
  37. <input type="text" class="tc-inp" placeholder="请输入卡号" v-model="code">
  38. <input type="text" class="tc-inp tc-inp-km" placeholder="请输入卡密" v-model="password" v-if="type == 2">
  39. <view class="tc-btn" @click="gonew">
  40. {{type==1?'立即发放':'立即核销'}}
  41. </view>
  42. <view class="" style="height: 50rpx;">
  43. </view>
  44. </view>
  45. </uni-popup>
  46. </view>
  47. </template>
  48. <script>
  49. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  50. import { sendStk, checkStk, getStk } from '@/api/user.js'
  51. export default {
  52. components: {
  53. uniPopup
  54. },
  55. data() {
  56. return {
  57. height: '',
  58. type: 0,
  59. code: '',//卡号
  60. password: '',//卡密
  61. uping: false,
  62. loaded: false,
  63. loadingType: 'more',
  64. page: 1,
  65. limit: 100,
  66. list: []
  67. }
  68. },
  69. onLoad(opt) {
  70. this.type = opt.type
  71. if (opt.type == 1) {
  72. uni.setNavigationBarTitle({
  73. title: '发放实体卡'
  74. })
  75. } else {
  76. uni.setNavigationBarTitle({
  77. title: '核销实体卡'
  78. })
  79. }
  80. this.getBase()
  81. },
  82. onShow() {
  83. console.log(this.$store.state.baseURL)
  84. },
  85. onReachBottom() {
  86. this.getBase()
  87. },
  88. onReady(res) {
  89. var obj = this;
  90. uni.getSystemInfo({
  91. success: resu => {
  92. const query = uni.createSelectorQuery();
  93. query.select('.stk-list-wrap').boundingClientRect();
  94. query.exec(function(res) {
  95. obj.height = resu.windowHeight - res[0].top + 'px';
  96. });
  97. },
  98. fail: res => {}
  99. });
  100. },
  101. methods: {
  102. getBase(type) {
  103. let obj = this
  104. if(type == 'reload') {
  105. obj.page = 1,
  106. obj.loadingType = 'more'
  107. obj.list = []
  108. }
  109. if(obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  110. return
  111. }
  112. obj.loadingType = 'loading'
  113. getStk({
  114. page: obj.page,
  115. limit: obj.limit,
  116. status: obj.type
  117. }).then(res => {
  118. console.log(res)
  119. obj.list = obj.list.concat(res.data.list.list.data)
  120. if(res.data.list.list.data.length == obj.limit) {
  121. obj.loadingType = 'more'
  122. }else {
  123. obj.loadingType = 'noMore'
  124. }
  125. })
  126. },
  127. opentc() {
  128. this.$refs.popupStk.open()
  129. },
  130. gonew() {
  131. let obj = this
  132. if(obj.uping) {
  133. return
  134. }
  135. if(obj.code == '') {
  136. return obj.$api.msg('请输入卡号')
  137. }
  138. if(obj.type == 2) {
  139. if(obj.password == '') {
  140. return obj.$api.msg('请输入卡密')
  141. }
  142. }
  143. obj.uping = true
  144. if(obj.type == 1) {
  145. sendStk({
  146. code: obj.code
  147. }).then(res => {
  148. obj.$refs.popupStk.close()
  149. obj.code = ''
  150. obj.password = ''
  151. obj.getBase('reload')
  152. uni.showToast({
  153. title:'发放成功',
  154. duration:2000
  155. });
  156. obj.uping = false
  157. }).catch(err => {
  158. obj.uping = false
  159. })
  160. }else if(obj.type == 2) {
  161. checkStk({
  162. code: obj.code,
  163. password: obj.password
  164. }).then(res => {
  165. obj.$refs.popupStk.close()
  166. obj.code = ''
  167. obj.password = ''
  168. obj.getBase('reload')
  169. uni.showToast({
  170. title:'核销成功',
  171. duration:2000
  172. });
  173. obj.uping = false
  174. }).catch(err => {
  175. obj.uping = false
  176. })
  177. }
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss">
  183. .stk-list-wrap {
  184. position: relative;
  185. padding-bottom: 156rpx;
  186. .btm-btn {
  187. // background-color: #f8f8f8;
  188. position: fixed;
  189. height: 156rpx;
  190. bottom: 0;
  191. width: 750rpx;
  192. display: flex;
  193. justify-content: center;
  194. align-items: center;
  195. .btn {
  196. border-radius: 20rpx;
  197. background-color: #901b21;
  198. color: #fff;
  199. width: 622rpx;
  200. height: 86rpx;
  201. line-height: 86rpx;
  202. text-align: center;
  203. }
  204. }
  205. .stk-wrap {
  206. width: 705rpx;
  207. height: 204rpx;
  208. margin: 0 auto 20rpx;
  209. position: relative;
  210. .stk-bg {
  211. width: 705rpx;
  212. height: 204rpx;
  213. position: absolute;
  214. top: 0;
  215. }
  216. .stk-name {
  217. position: absolute;
  218. display: flex;
  219. height: 40rpx;
  220. align-items: center;
  221. font-size: 36rpx;
  222. color: #6b4713;
  223. font-weight: bold;
  224. top: 46rpx;
  225. left: 24rpx;
  226. image {
  227. width: 39rpx;
  228. height: 36rpx;
  229. margin-right: 10rpx;
  230. }
  231. }
  232. .stk-info {
  233. position: absolute;
  234. bottom: 0;
  235. height: 90rpx;
  236. width: 705rpx;
  237. padding: 0 24rpx;
  238. font-size: 26rpx;
  239. .info-no {
  240. text {
  241. color: #8f1b1f;
  242. }
  243. }
  244. // background-color: red;
  245. }
  246. }
  247. }
  248. .stk-tc {
  249. width: 560rpx;
  250. // height: 550rpx;
  251. background-color: #fff;
  252. border-radius: 20rpx;
  253. position: relative;
  254. .gift, .gift-bg, .gift-bg-mb, {
  255. position: absolute;
  256. left: 0;
  257. right: 0;
  258. margin: auto;
  259. }
  260. .tc-tit, .tc-inp, .tc-btn {
  261. margin: auto;
  262. }
  263. .gift {
  264. top: -93rpx;
  265. width: 177rpx;
  266. height: 186rpx;
  267. }
  268. .gift-bg-mb {
  269. top: 0;
  270. width: 456rpx;
  271. height: 90rpx;
  272. background-color: #fff;
  273. }
  274. .gift-bg {
  275. top: -90rpx;
  276. width: 456rpx;
  277. height: 180rpx;
  278. }
  279. .tc-tit {
  280. font-weight: bold;
  281. color: #333333;
  282. font-size: 36rpx;
  283. text-align: center;
  284. }
  285. .tc-inp {
  286. display: block;
  287. margin: 20rpx auto;
  288. width: 440rpx;
  289. height: 70rpx;
  290. background-color: #f5f5f5;
  291. top: 210rpx;
  292. padding-left: 20rpx;
  293. border-radius: 15rpx;
  294. font-size: 32rpx;
  295. }
  296. .tc-inp-km {
  297. top: 305rpx;
  298. }
  299. .tc-btn {
  300. width: 405rpx;
  301. height: 86rpx;
  302. margin-top: 45rpx;
  303. background-color: #901b21;
  304. border-radius: 43rpx;
  305. text-align: center;
  306. color: #fff;
  307. line-height: 86rpx;
  308. font-size: 36rpx;
  309. }
  310. }
  311. </style>