myex.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. <template>
  2. <view class="content">
  3. <view class="navbar">
  4. <view v-for="(itemn, index) in navList" :key="index" class="nav-item"
  5. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ itemn.text }}</view>
  6. </view>
  7. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" :style="{ height: height}"
  8. @change="changeTab">
  9. <swiper-item v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  10. <scroll-view scroll-y="true" :style="{ height: height}" style="padding-top: 20rpx;"
  11. @scrolltolower="getMyex()">
  12. <empty v-if="tabItem.loaded && tabItem.list.length === 0"></empty>
  13. <view class="order-item" v-for="i in tabItem.list" :key="i.id">
  14. <view class="i-td">
  15. <view class="td-left">订单编号:{{ i.order_id }}</view>
  16. <view class="td-right" v-if="i.status == 0" style="color: #901b21;font-weight: bold;">未使用
  17. </view>
  18. <view class="td-right" v-if="i.status == 1">已使用</view>
  19. </view>
  20. <view class="goods-box">
  21. <view class="goods-left flex">
  22. <image class="goods-img"
  23. :src="i.cart_info.productInfo.image || '../../static/error/errorImage.jpg'"></image>
  24. <view class="goods-name">
  25. <view class="p clamp2">{{ i.cart_info.productInfo.store_name }}</view>
  26. </view>
  27. </view>
  28. <view class="goods-price">
  29. <!-- <view class="">¥{{ price(i.price) }}</view> -->
  30. <!-- <view class="num">x{{ item.cart_num }}</view> -->
  31. <br />
  32. </view>
  33. </view>
  34. <view class="i-td">
  35. <view class="td-left"></view>
  36. <view class="i-bottom clamp" v-if="i.gift_uid == userInfo.uid">由{{i.user.nickname}}赠送</view>
  37. <view class="i-bottom clamp" v-if="i.gift_uid != 0 && i.gift_uid !== userInfo.uid"
  38. style="font-size: 28rpx; color: #999;">已赠送给{{i.gift_user.nickname}}</view>
  39. <view class="i-bottom" style="">
  40. <text>合计 ¥{{ i.pay_price*1 + i.deposit*1}}</text>
  41. </view>
  42. </view>
  43. <view class="btn-box">
  44. <!-- <view class="clamp" style="font-size: 28rpx; color: #999;" v-if="i.gift_uid == userInfo.uid">由{{i.user.nickname}}赠送</view>
  45. <view class="clamp" v-if="i.gift_uid != 0 && i.gift_uid !== userInfo.uid" style="font-size: 28rpx; color: #999;">已赠送给{{i.gift_user.nickname}}</view> -->
  46. <view class="btn" @click.stop="showCode(i)"
  47. v-if="i.status == 0 && i.gift_uid == userInfo.uid">出示券码
  48. </view>
  49. <view class="btn" @click.stop="showCode(i)" v-if="i.status == 0 && i.gift_uid == 0">出示券码
  50. </view>
  51. <view class="btn" @click.stop="shareF(i)" v-if="i.status == 0 && i.gift_uid == 0">赠送好友
  52. </view>
  53. </view>
  54. </view>
  55. </scroll-view>
  56. </swiper-item>
  57. </swiper>
  58. <!-- <uni-load-more :status="loadingType"></uni-load-more>
  59. <uni-popup ref="popuphx" class="agree-wrapper">
  60. </uni-popup> -->
  61. </view>
  62. </template>
  63. <script>
  64. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  65. import empty from '@/components/empty';
  66. import {
  67. orderList,
  68. orderGive,
  69. getUserList,
  70. getMyexchange
  71. } from '../../api/order.js'
  72. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  73. import {
  74. mapState,
  75. mapMutations
  76. } from 'vuex';
  77. export default {
  78. components: {
  79. uniLoadMore,
  80. empty,
  81. uniPopup
  82. },
  83. computed: {
  84. ...mapState('user', ['userInfo']),
  85. canPut() {
  86. return this.chooseuser == '' ? false : true
  87. }
  88. },
  89. data() {
  90. return {
  91. height: '',
  92. tabCurrentIndex: 0,
  93. navList: [{
  94. type: 0,
  95. text: '未使用',
  96. list: [],
  97. page: 1,
  98. limit: 10,
  99. loadingType: 'more',
  100. loaded: false,
  101. },
  102. {
  103. type: 1,
  104. text: '已使用',
  105. list: [],
  106. page: 1,
  107. limit: 10,
  108. loadingType: 'more',
  109. loaded: false,
  110. }, {
  111. type: 9,
  112. text: '已送出',
  113. list: [],
  114. page: 1,
  115. limit: 10,
  116. loadingType: 'more',
  117. loaded: false,
  118. }
  119. ],
  120. list: [],
  121. page: 1,
  122. limit: 10,
  123. loadingType: 'more',
  124. loaded: false,
  125. toname: '',
  126. jzUid: '',
  127. wxId: '',
  128. // userList: [],
  129. // canPut: false,//是否可转
  130. showList: [],
  131. userList: [],
  132. chooseuser: '',
  133. userData: {},
  134. userLoaded: false
  135. }
  136. },
  137. onShow() {
  138. this.getMyex()
  139. // this.getUserList()
  140. },
  141. // onReachBottom() {
  142. // this.getMyex()
  143. // },
  144. onReady() {
  145. var obj = this;
  146. uni.getSystemInfo({
  147. success: resu => {
  148. const query = uni.createSelectorQuery();
  149. query.select('.swiper-box').boundingClientRect();
  150. query.exec(function(res) {
  151. console.log(res, 'ddddddddddddd');
  152. obj.height = resu.windowHeight - res[0].top + 'px';
  153. console.log('打印页面的剩余高度', obj.height);
  154. });
  155. },
  156. fail: res => {}
  157. });
  158. },
  159. methods: {
  160. //swiper 切换
  161. changeTab(e) {
  162. this.tabCurrentIndex = e.target.current;
  163. this.getMyex('tab');
  164. },
  165. //swiper 切换
  166. changeTab(e) {
  167. this.tabCurrentIndex = e.target.current;
  168. this.getMyex('tab');
  169. },
  170. //顶部tab点击
  171. tabClick(index) {
  172. this.tabCurrentIndex = index;
  173. this.getMyex('tab');
  174. },
  175. getUserList() {
  176. let obj = this
  177. getUserList({
  178. keyword: obj.toname
  179. }).then(res => {
  180. console.log(res, 'userList')
  181. this.showList = []
  182. this.chooseuser = ''
  183. this.userData = {}
  184. this.userList = res.data
  185. this.userLoaded = true
  186. res.data.forEach(item => {
  187. this.showList.push('ID:' + item.uid + ',昵称:' + item.nickname)
  188. })
  189. })
  190. },
  191. price(price) {
  192. return (price * 1).toFixed(2);
  193. },
  194. getMyex(tab) {
  195. let obj = this
  196. let index = obj.tabCurrentIndex
  197. let navItem = obj.navList[index]
  198. if (navItem.loadingType == 'loading' || navItem.loadingType == 'noMore') {
  199. return
  200. }
  201. if(tab == 'tab' && navItem.loaded ) {
  202. return
  203. }
  204. navItem.loadingType = 'loading'
  205. getMyexchange({
  206. // type: 10086,
  207. page: navItem.page,
  208. limit: navItem.limit,
  209. type: navItem.type
  210. }).then(({
  211. data
  212. }) => {
  213. navItem.list = navItem.list.concat(data)
  214. navItem.page++
  215. if (data.length == navItem.limit) {
  216. navItem.loadingType = 'more'
  217. return
  218. } else {
  219. navItem.loadingType = 'noMore'
  220. }
  221. obj.$set(navItem, 'loaded', true)
  222. })
  223. },
  224. showCode(e) {
  225. uni.navigateTo({
  226. url: '/pages/order/verifyCode?id=' + e.order_id + '&type=exchange' + '&vcode=' + e.verify_code
  227. })
  228. },
  229. shareF(e) {
  230. console.log(e)
  231. let obj = this
  232. this.wxId = e.order_id
  233. uni.navigateTo({
  234. url: '/user/page/shareEx?shareid=' + e.id + '&scene=' + obj.userInfo.uid + '&logo=' + obj
  235. .userInfo.avatar + '&nickname=' + obj.userInfo.nickname + '&goodimg=' + e.cart_info
  236. .productInfo.image + '&type=1'
  237. })
  238. // this.$refs.popuphx.open()
  239. // orderGive({
  240. // },e.cartInfo[0].product_attr_unique).then(res => {
  241. // console.log(res)
  242. // })
  243. },
  244. qhx() {
  245. let obj = this
  246. if (obj.userData == '') {
  247. obj.$api.msg('请选择好友')
  248. return
  249. }
  250. orderGive({
  251. uid: obj.userData.uid
  252. }, this.wxId).then(res => {
  253. console.log(res)
  254. console.log()
  255. obj.$refs.popuphx.close()
  256. uni.showToast({
  257. title: '赠送成功',
  258. duration: 2000
  259. });
  260. obj.page = 1
  261. obj.list = []
  262. obj.loadingType = 'more'
  263. obj.getMyex()
  264. })
  265. },
  266. close() {
  267. this.$refs.popuphx.close()
  268. this.jzUid = ''
  269. this.wxId = ''
  270. },
  271. PickerDire(e) {
  272. console.log(e, 'xuan')
  273. this.chooseuser = this.showList[e.detail.value]
  274. this.userData = this.userList[e.detail.value]
  275. }
  276. }
  277. }
  278. </script>
  279. <style lang="scss" scoped>
  280. page {
  281. height: 100%;
  282. }
  283. .navbar {
  284. display: flex;
  285. height: 40px;
  286. padding: 0 5px;
  287. background: #fff;
  288. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  289. position: relative;
  290. z-index: 10;
  291. .nav-item {
  292. flex: 1;
  293. display: flex;
  294. justify-content: center;
  295. align-items: center;
  296. height: 100%;
  297. font-size: 15px;
  298. color: $font-color-dark;
  299. position: relative;
  300. &.current {
  301. color: $base-color;
  302. &:after {
  303. content: '';
  304. position: absolute;
  305. left: 50%;
  306. bottom: 0;
  307. transform: translateX(-50%);
  308. width: 44px;
  309. height: 0;
  310. border-bottom: 2px solid $base-color;
  311. }
  312. }
  313. }
  314. }
  315. .swiper-box,
  316. .tab-content,
  317. .scroll-y {
  318. height: calc(100vh - 44px);
  319. }
  320. .order-item {
  321. display: grid;
  322. margin-bottom: 20rpx;
  323. }
  324. .btn-box {
  325. border-top: 1px solid #f2f2f2;
  326. height: 100rpx;
  327. width: 100%;
  328. padding-right: 20rpx;
  329. background-color: #ffffff;
  330. display: flex;
  331. justify-content: flex-end;
  332. align-items: center;
  333. .btn {
  334. margin-left: 10rpx;
  335. width: 144rpx;
  336. height: 55rpx;
  337. border: 1px solid #901b21;
  338. border-radius: 28rpx;
  339. font-size: 26rpx;
  340. font-family: PingFang SC;
  341. font-weight: 500;
  342. color: #901b21;
  343. line-height: 55rpx;
  344. text-align: center;
  345. }
  346. .btn-look {
  347. margin-left: 10rpx;
  348. width: 144rpx;
  349. height: 55rpx;
  350. border: 1px solid #ebebeb;
  351. border-radius: 28rpx;
  352. font-size: 26rpx;
  353. font-family: PingFang SC;
  354. font-weight: 500;
  355. color: #999999;
  356. line-height: 55rpx;
  357. text-align: center;
  358. }
  359. }
  360. .i-td {
  361. display: flex;
  362. justify-content: space-between;
  363. background-color: #ffffff;
  364. padding: 20rpx;
  365. color: #999999;
  366. font-size: 25rpx;
  367. .i-bottom {
  368. span {
  369. margin: 0 10rpx;
  370. b {
  371. font-size: 28rpx;
  372. color: #4f4f4f;
  373. }
  374. }
  375. }
  376. }
  377. .goods-box {
  378. height: 100%;
  379. display: flex;
  380. justify-content: space-between;
  381. background-color: #f7f7f7;
  382. padding: 20rpx;
  383. .goods-left {
  384. align-items: flex-start;
  385. .goods-img {
  386. width: 160rpx;
  387. height: 160rpx;
  388. }
  389. .goods-name {
  390. margin: 10rpx 40rpx;
  391. color: #666666;
  392. font-size: 30rpx;
  393. .p {
  394. max-width: 300rpx;
  395. margin-bottom: 10rpx;
  396. }
  397. .span {
  398. width: 120rpx;
  399. background-color: #ffeae5;
  400. color: #fd5b23;
  401. text-align: center;
  402. font-size: 24rpx;
  403. padding: 5rpx;
  404. border-radius: 5rpx;
  405. }
  406. }
  407. }
  408. .goods-price {
  409. margin: 10rpx 0;
  410. text-align: right;
  411. display: grid;
  412. color: #999999;
  413. font-size: 24rpx;
  414. position: relative;
  415. b {
  416. color: #901b21;
  417. font-size: 35rpx;
  418. }
  419. .num {
  420. position: absolute;
  421. bottom: 20rpx;
  422. right: 10rpx;
  423. }
  424. }
  425. }
  426. .hx-wrapper {
  427. width: 536rpx;
  428. height: 630rpx;
  429. position: relative;
  430. // background-color: #fff;
  431. .hx-img {
  432. width: 536rpx;
  433. height: 281rpx;
  434. image {
  435. width: 536rpx;
  436. height: 281rpx;
  437. }
  438. }
  439. .hx-close {
  440. position: absolute;
  441. left: 243rpx;
  442. bottom: -80rpx;
  443. width: 52rpx;
  444. height: 52rpx;
  445. image {
  446. width: 52rpx;
  447. height: 52rpx;
  448. }
  449. }
  450. .hx-body {
  451. width: 536rpx;
  452. height: 300rpx;
  453. background-color: #fff;
  454. border-radius: 0 0 10rpx 10rpx;
  455. .hx-title {
  456. width: 536rpx;
  457. font-size: 36rpx;
  458. font-weight: 500;
  459. color: #333333;
  460. line-height: 1;
  461. padding-top: 42rpx;
  462. text-align: center;
  463. }
  464. .choose-user {
  465. width: 439rpx;
  466. margin: 20rpx auto 0;
  467. }
  468. input {
  469. width: 439rpx;
  470. height: 68rpx;
  471. background: #eeddde;
  472. border-radius: 10rpx;
  473. margin: 0rpx auto 0;
  474. padding-left: 26rpx;
  475. .hx-placeholder {
  476. font-size: 26rpx;
  477. font-weight: 500;
  478. color: #901b21;
  479. }
  480. }
  481. .hx-btn {
  482. margin: 44rpx auto 0;
  483. width: 353rpx;
  484. height: 71rpx;
  485. background: #901b21;
  486. border-radius: 34rpx;
  487. font-size: 36rpx;
  488. font-weight: 500;
  489. color: #F8F9F9;
  490. line-height: 71rpx;
  491. text-align: center;
  492. }
  493. .action {
  494. background: #999
  495. }
  496. }
  497. }
  498. </style>