userCard.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <template>
  2. <view class="content">
  3. <view class="flex nav-list">
  4. <view class="item" v-for="(item,index) in navList" :class="{'action': current == index}"
  5. @click="changeNavT(index)">
  6. {{item.tit}} <text >({{item.count}})</text>
  7. </view>
  8. </view>
  9. <swiper class="good-content" :style="{'height':height }" :current="current">
  10. <swiper-item v-for="item in navList" :style="{'height':height }">
  11. <scroll-view class="padding-t-30" scroll-y="true" :style="{'height':height }" @scrolltolower="getList">
  12. <view class="dyquan-wrap" v-for="(itemt,index) in item.list" :key="index">
  13. <view class="showtime">
  14. <text class="float_left order-no-text">{{ itemt.verify_code|| '' }}</text>
  15. </view>
  16. <view class="item-info">
  17. <image src="../../static/img/tyq.png" mode=""></image>
  18. <view class="info-info">
  19. <view class="clamp2">
  20. 太空舱体验券
  21. </view>
  22. <view class="clamp2">
  23. X1
  24. </view>
  25. </view>
  26. </view>
  27. <view class="btm">
  28. <view v-if="itemt.status == 0 && itemt.source_uid == 0" class="btn" @click="giveFriend(itemt.id)">
  29. 转赠好友
  30. </view>
  31. <view v-if="itemt.status == 0 && itemt.source_uid != userInfo.uid" class="btn btn-2" @click="navto(itemt.verify_code)">
  32. 立即使用
  33. </view>
  34. </view>
  35. </view>
  36. <uni-load-more v-if="!(item.list == 0 && item.loaded)" :status="item.loadingType"></uni-load-more>
  37. <empty v-else></empty>
  38. </scroll-view>
  39. </swiper-item>
  40. </swiper>
  41. <!-- 核销弹窗 -->
  42. <uni-popup ref="popuphx" class="agree-wrapper">
  43. <view class="hx-wrapper">
  44. <view class="hx-img">
  45. <image src="../../static/img/hxbg.png" mode=""></image>
  46. </view>
  47. <view class="hx-body">
  48. <view class="hx-title">
  49. 接收人UID
  50. </view>
  51. <input type="text" v-model="code" placeholder="请输入接收人UID" placeholder-class="hx-placeholder" />
  52. <view class="hx-btn" @click="qhx">
  53. 赠送
  54. </view>
  55. </view>
  56. <view class="hx-close" @click="close">
  57. <image src="../../static/icon/close.png" mode=""></image>
  58. </view>
  59. </view>
  60. </uni-popup>
  61. </view>
  62. </template>
  63. <script>
  64. import {
  65. mapState,
  66. mapMutations
  67. } from 'vuex';
  68. import { getUserCard,giveCard} from '@/api/user.js'
  69. import empty from '@/components/empty';
  70. export default {
  71. components: {
  72. empty
  73. },
  74. data() {
  75. return {
  76. code: '',
  77. give_id: 0,
  78. height: '',
  79. current: 0,
  80. navList: [
  81. {
  82. count: 0,
  83. status: -1,
  84. tit: '全部',
  85. list: [],
  86. page: 1,
  87. limit: 10,
  88. loaded: false,
  89. loadingType: 'more'
  90. },{
  91. count: 0,
  92. status: 0,
  93. tit: '待使用',
  94. list: [],
  95. page: 1,
  96. limit: 10,
  97. loaded: false,
  98. loadingType: 'more'
  99. },
  100. {
  101. count: 0,
  102. status: 1,
  103. tit: '已使用',
  104. list: [],
  105. page: 1,
  106. limit: 10,
  107. loaded: false,
  108. loadingType: 'more'
  109. },
  110. ]
  111. }
  112. },
  113. onLoad() {
  114. this.getNumBase();
  115. },
  116. computed: {
  117. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  118. },
  119. onShow() {
  120. console.log('ddd ')
  121. this.getList('re')
  122. },
  123. onReachBottom() {
  124. },
  125. onReady(res) {
  126. var that = this;
  127. uni.getSystemInfo({
  128. success: resu => {
  129. const query = uni.createSelectorQuery();
  130. query.select('.good-content').boundingClientRect();
  131. query.exec(function(res) {
  132. that.height = resu.windowHeight - res[0].top + 'px';
  133. });
  134. },
  135. fail: res => {}
  136. });
  137. },
  138. methods: {
  139. getNumBase(){
  140. const that = this;
  141. for(let i =0;i<that.navList.length;i++){
  142. const item = that.navList[i];
  143. console.log(item,'item');
  144. getUserCard({
  145. uid: that.userInfo.uid,
  146. page: item.page,
  147. limit: item.limit,
  148. status: item.status
  149. }).then(res => {
  150. item.count = res.data.count;
  151. console.log(item,'item.222')
  152. console.log(item==that.navList[i])
  153. })
  154. }
  155. },
  156. qhx() {
  157. if(!this.code) {
  158. return this.$api.msg('请输入接收人UID')
  159. }
  160. if(this.code == this.userInfo.uid) {
  161. return this.$api.msg('接收人不能为自己')
  162. }
  163. console.log(this.give_id)
  164. giveCard({
  165. id: this.give_id,
  166. to_uid:this.code
  167. }).then(res => {
  168. uni.showToast({
  169. icon:'success',
  170. title:'赠送成功'
  171. })
  172. this.close()
  173. this.getList('re')
  174. })
  175. },
  176. close() {
  177. this.code = ''
  178. this.give_id = ''
  179. this.$refs.popuphx.close()
  180. },
  181. navto(val) {
  182. uni.navigateTo({
  183. url: '/pages/user/hxqm?val=' + val
  184. })
  185. },
  186. giveFriend(id) {
  187. console.log(id)
  188. this.give_id = id
  189. this.$refs.popuphx.open()
  190. },
  191. changeNavT(index) {
  192. if (index == this.current) {
  193. return
  194. }
  195. this.current = index
  196. this.getList('re')
  197. },
  198. getList(type) {
  199. let that = this
  200. let item = that.navList[that.current]
  201. if(type == 're') {
  202. item.page = 1
  203. item.list = []
  204. item.loadingType = 'more'
  205. }
  206. if(item.loadingType == 'loading' || item.loadingType == 'noMore') {
  207. return
  208. }
  209. item.loadingType = 'loading'
  210. getUserCard({
  211. uid: that.userInfo.uid,
  212. page: item.page,
  213. limit: item.limit,
  214. status: item.status
  215. }).then(res => {
  216. let arr = res.data.list
  217. item.list = item.list.concat(arr)
  218. item.count = res.data.count
  219. if(item.limit == arr.length) {
  220. item.loadingType = 'more'
  221. item.page++
  222. }else {
  223. item.loadingType = 'noMore'
  224. }
  225. item.loaded = true
  226. })
  227. }
  228. }
  229. }
  230. </script>
  231. <style lang="scss" scoped>
  232. .nav-list {
  233. justify-content: space-around;
  234. background-color: #fff;
  235. font-weight: 500;
  236. color: #333333;
  237. .item {
  238. padding: 28rpx 20rpx 16rpx;
  239. }
  240. .action {
  241. color: #333;
  242. font-weight: bold;
  243. border-bottom: 2px solid $base-color;
  244. }
  245. }
  246. .dyquan-wrap {
  247. padding: 30rpx;
  248. background-color: #fff;
  249. margin:0 30rpx 30rpx 30rpx;
  250. border-radius: 20rpx;
  251. .showtime {
  252. height: 50rpx;
  253. border-bottom: 1px solid $uni-border-color;
  254. }
  255. .item-info {
  256. height: 205rpx;
  257. display: flex;
  258. justify-content: flex-start;
  259. align-items: center;
  260. image {
  261. width: 160rpx;
  262. height: 160rpx;
  263. margin-right: 30rpx;
  264. }
  265. .info-info {
  266. height: 160rpx;
  267. padding: 15rpx 0;
  268. padding-right: 50rpx;
  269. font-size: 30rpx;
  270. font-weight: 500;
  271. color: #666666;
  272. display: flex;
  273. flex-direction: column;
  274. justify-content: space-between;
  275. align-items: flex-start;
  276. .info-cs {
  277. font-size: 26rpx;
  278. font-weight: 500;
  279. color: #999999;
  280. }
  281. }
  282. }
  283. .btn-list {
  284. }
  285. .btm {
  286. width: 100%;
  287. background-color: #fff;
  288. display: flex;
  289. justify-content: flex-end;
  290. align-items: center;
  291. .btn {
  292. width: 144rpx;
  293. height: 55rpx;
  294. border-radius: 28rpx;
  295. font-size: 26rpx;
  296. font-weight: 500;
  297. color:$base-color;
  298. line-height: 55rpx;
  299. text-align: center;
  300. border: 1px solid $base-color;
  301. }
  302. .btn-2 {
  303. background-color: $base-color;color: #fff;
  304. margin-left: 15rpx;
  305. }
  306. }
  307. }
  308. .hx-wrapper {
  309. width: 536rpx;
  310. // height: 630rpx;
  311. position: relative;
  312. padding-bottom: 40rpx;
  313. background-color: #fff;
  314. border-radius: 20rpx;
  315. .hx-img {
  316. width: 536rpx;
  317. height: 281rpx;
  318. image {
  319. width: 536rpx;
  320. height: 281rpx;
  321. }
  322. }
  323. .hx-close {
  324. position: absolute;
  325. left: 243rpx;
  326. bottom: -80rpx;
  327. width: 52rpx;
  328. height: 52rpx;
  329. image {
  330. width: 52rpx;
  331. height: 52rpx;
  332. }
  333. }
  334. .hx-body {
  335. width: 536rpx;
  336. // min-height: 349rpx;
  337. background-color: #fff;
  338. border-radius: 0 0 10rpx 10rpx;
  339. padding-top: 40rpx;
  340. .hx-title {
  341. width: 536rpx;
  342. font-size: 36rpx;
  343. font-weight: 500;
  344. color: #333333;
  345. line-height: 1;
  346. padding-top: 20rpx;
  347. text-align: center;
  348. padding-bottom: 20rpx;
  349. }
  350. input {
  351. width: 439rpx;
  352. height: 68rpx;
  353. background: #f1faf6;
  354. border-radius: 10rpx;
  355. margin: 0 auto 40rpx;
  356. padding-left: 26rpx;
  357. .hx-placeholder {
  358. font-size: 26rpx;
  359. font-weight: 500;
  360. color: $base-color;
  361. }
  362. }
  363. .hx-btn {
  364. margin: 44rpx auto 0;
  365. width: 353rpx;
  366. height: 71rpx;
  367. background: $base-color;
  368. border-radius: 34rpx;
  369. font-size: 36rpx;
  370. font-weight: 500;
  371. color: #F8F9F9;
  372. line-height: 71rpx;
  373. text-align: center;
  374. }
  375. }
  376. }
  377. </style>