userCard.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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 v-if="item.loaded">({{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 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. },
  115. computed: {
  116. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  117. },
  118. onShow() {
  119. console.log('ddd ')
  120. this.getList('re')
  121. },
  122. onReachBottom() {
  123. },
  124. onReady(res) {
  125. var that = this;
  126. uni.getSystemInfo({
  127. success: resu => {
  128. const query = uni.createSelectorQuery();
  129. query.select('.good-content').boundingClientRect();
  130. query.exec(function(res) {
  131. that.height = resu.windowHeight - res[0].top + 'px';
  132. });
  133. },
  134. fail: res => {}
  135. });
  136. },
  137. methods: {
  138. qhx() {
  139. if(!this.code) {
  140. return this.$api.msg('请输入接收人UID')
  141. }
  142. if(this.code == this.userInfo.uid) {
  143. return this.$api.msg('接收人不能为自己')
  144. }
  145. console.log(this.give_id)
  146. giveCard({
  147. id: this.give_id,
  148. to_uid:this.code
  149. }).then(res => {
  150. uni.showToast({
  151. icon:'success',
  152. title:'赠送成功'
  153. })
  154. this.close()
  155. this.getList('re')
  156. })
  157. },
  158. close() {
  159. this.code = ''
  160. this.give_id = ''
  161. this.$refs.popuphx.close()
  162. },
  163. navto(val) {
  164. uni.navigateTo({
  165. url: '/pages/user/hxqm?val=' + val
  166. })
  167. },
  168. giveFriend(id) {
  169. console.log(id)
  170. this.give_id = id
  171. this.$refs.popuphx.open()
  172. },
  173. changeNavT(index) {
  174. if (index == this.current) {
  175. return
  176. }
  177. this.current = index
  178. this.getList('re')
  179. },
  180. getList(type) {
  181. let that = this
  182. let item = that.navList[that.current]
  183. if(type == 're') {
  184. item.page = 1
  185. item.list = []
  186. item.loadingType = 'more'
  187. }
  188. if(item.loadingType == 'loading' || item.loadingType == 'noMore') {
  189. return
  190. }
  191. item.loadingType = 'loading'
  192. getUserCard({
  193. uid: that.userInfo.uid,
  194. page: item.page,
  195. limit: item.limit,
  196. status: item.status
  197. }).then(res => {
  198. let arr = res.data.list
  199. item.list = item.list.concat(arr)
  200. item.count = res.data.count
  201. if(item.limit == arr.length) {
  202. item.loadingType = 'more'
  203. item.page++
  204. }else {
  205. item.loadingType = 'noMore'
  206. }
  207. item.loaded = true
  208. })
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang="scss" scoped>
  214. .nav-list {
  215. justify-content: space-around;
  216. background-color: #fff;
  217. font-weight: 500;
  218. color: #333333;
  219. .item {
  220. padding: 28rpx 20rpx 16rpx;
  221. }
  222. .action {
  223. color: #333;
  224. font-weight: bold;
  225. border-bottom: 2px solid $base-color;
  226. }
  227. }
  228. .dyquan-wrap {
  229. padding: 20rpx;
  230. background-color: #fff;
  231. margin-bottom: 15rpx;
  232. .showtime {
  233. height: 50rpx;
  234. }
  235. .item-info {
  236. width: 750rpx;
  237. height: 205rpx;
  238. background: #F7F7F7;
  239. display: flex;
  240. justify-content: flex-start;
  241. align-items: center;
  242. image {
  243. width: 160rpx;
  244. height: 160rpx;
  245. margin-right: 30rpx;
  246. }
  247. .info-info {
  248. height: 160rpx;
  249. padding: 15rpx 0;
  250. padding-right: 50rpx;
  251. font-size: 30rpx;
  252. font-weight: 500;
  253. color: #666666;
  254. display: flex;
  255. flex-direction: column;
  256. justify-content: space-between;
  257. align-items: flex-start;
  258. .info-cs {
  259. font-size: 26rpx;
  260. font-weight: 500;
  261. color: #999999;
  262. }
  263. }
  264. }
  265. .btn-list {
  266. }
  267. .btm {
  268. width: 100%;
  269. height: 95rpx;
  270. background-color: #fff;
  271. display: flex;
  272. justify-content: flex-end;
  273. align-items: center;
  274. .btn {
  275. width: 144rpx;
  276. height: 55rpx;
  277. border-radius: 28rpx;
  278. font-size: 26rpx;
  279. font-weight: 500;
  280. color:$base-color;
  281. line-height: 55rpx;
  282. text-align: center;
  283. border: 1px solid $base-color;
  284. }
  285. .btn-2 {
  286. background-color: $base-color;color: #fff;
  287. margin-left: 15rpx;
  288. }
  289. }
  290. }
  291. .hx-wrapper {
  292. width: 536rpx;
  293. // height: 630rpx;
  294. position: relative;
  295. padding-bottom: 40rpx;
  296. background-color: #fff;
  297. border-radius: 20rpx;
  298. .hx-img {
  299. width: 536rpx;
  300. height: 281rpx;
  301. image {
  302. width: 536rpx;
  303. height: 281rpx;
  304. }
  305. }
  306. .hx-close {
  307. position: absolute;
  308. left: 243rpx;
  309. bottom: -80rpx;
  310. width: 52rpx;
  311. height: 52rpx;
  312. image {
  313. width: 52rpx;
  314. height: 52rpx;
  315. }
  316. }
  317. .hx-body {
  318. width: 536rpx;
  319. // min-height: 349rpx;
  320. background-color: #fff;
  321. border-radius: 0 0 10rpx 10rpx;
  322. padding-top: 40rpx;
  323. .hx-title {
  324. width: 536rpx;
  325. font-size: 36rpx;
  326. font-weight: 500;
  327. color: #333333;
  328. line-height: 1;
  329. padding-top: 20rpx;
  330. text-align: center;
  331. padding-bottom: 20rpx;
  332. }
  333. input {
  334. width: 439rpx;
  335. height: 68rpx;
  336. background: #f1faf6;
  337. border-radius: 10rpx;
  338. margin: 0 auto 40rpx;
  339. padding-left: 26rpx;
  340. .hx-placeholder {
  341. font-size: 26rpx;
  342. font-weight: 500;
  343. color: $base-color;
  344. }
  345. }
  346. .hx-btn {
  347. margin: 44rpx auto 0;
  348. width: 353rpx;
  349. height: 71rpx;
  350. background: $base-color;
  351. border-radius: 34rpx;
  352. font-size: 36rpx;
  353. font-weight: 500;
  354. color: #F8F9F9;
  355. line-height: 71rpx;
  356. text-align: center;
  357. }
  358. }
  359. }
  360. </style>