userCard.vue 7.6 KB

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