OrderList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div member-order-list">
  3. <view class="div common-header-wrap">
  4. <view class="status-holder"></view>
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="兑换记录" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <!-- header -->
  14. <view class="div order-header">
  15. <view class="ul">
  16. <view
  17. class="li item"
  18. v-for="item in orderNav"
  19. v-bind:key="item.id"
  20. v-bind:class="{ active: stateType == item.id }"
  21. v-on:click="setOrderNavActive(item.id)"
  22. >
  23. {{ item.name }}
  24. </view>
  25. </view>
  26. </view>
  27. <view class="scroll-view div" style="position:relative">
  28. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" class="div" @scrolltolower="loadMore" scroll-y="true">
  29. <view class="div order-body" v-if="order_list && order_list.length" >
  30. <view class="div list" v-for="item in order_list" :key="item.point_orderid">
  31. <view class="div" @click="goNavigate('/pages/member/pointsorder/OrderDetail',{point_orderid:item.point_orderid})">
  32. <view class="div tips-body">
  33. <text class="span tips"> 订单编号: {{ item.point_ordersn }} </text>
  34. <text class="span title tips statusTips" >
  35. {{ item.point_orderstatetext }}
  36. </text>
  37. </view>
  38. <view class="div order-image">
  39. <view class="div goods_info clearfix" v-for="(image,index) in item.prodlist" :key="index" >
  40. <view class="div img-wrapper">
  41. <image mode="aspectFit" class="img" v-bind:src="image.pointog_goodsimage" />
  42. </view>
  43. <view class="p goods_name">{{image.pointog_goodsname}}</view>
  44. <view class="p goods_points">
  45. <view class="points">¥{{image.pointog_goodspoints}}</view>
  46. <view class="num">X{{image.pointog_goodsnum}}</view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="div order_amount">
  51. (共计{{ item.prodlist.length }}种商品) 合计 : <text class="order_amount_icon">¥</text><text class="i">{{ item.point_allpoint }}积分</text>
  52. </view>
  53. </view>
  54. <view class="div order-list-opratio">
  55. <!-- 收货 -->
  56. <text v-if="item.point_orderstate =='30'" v-on:click="receive(item.point_orderid)" class="button line_red">收货</text>
  57. <!-- 取消 -->
  58. <text v-if="item.point_orderstate =='20'" v-on:click="cancel(item.point_orderid)" class="button line_red">取消</text>
  59. </view>
  60. </view>
  61. </view>
  62. <empty-record v-else-if="order_list && !order_list.length"></empty-record>
  63. </scroll-view>
  64. </view>
  65. </view>
  66. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  67. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  68. </uni-popup>
  69. </member-base>
  70. </template>
  71. <script>
  72. import {getFontSize} from '@/util/common'
  73. import TitleHeader from '../../TitleHeader'
  74. import { urlencode } from '@/util/common'
  75. import MemberBase from '../MemberBase'
  76. import { getOrderList, cancelOrder, receiveOrder } from '../../../api/memberPointsorder'
  77. import { mapState } from 'vuex'
  78. import EmptyRecord from '../../EmptyRecord'
  79. export default {
  80. components:{
  81. TitleHeader,
  82. MemberBase,
  83. EmptyRecord
  84. },
  85. name:'MemberOrderList',
  86. data(){
  87. return {
  88. navHeight: 0,
  89. dialog:{},
  90. order_id: 0,
  91. orderNav: [
  92. {
  93. 'name': '全部',
  94. 'id': ''
  95. },
  96. {
  97. 'name': '待发货',
  98. 'id': 'state_pay'
  99. },
  100. {
  101. 'name': '待收货',
  102. 'id': 'state_send'
  103. },
  104. {
  105. 'name': '已取消',
  106. 'id': 'state_cancel'
  107. },
  108. {
  109. 'name': '已完成',
  110. 'id': 'state_finish'
  111. }
  112. ],
  113. stateType: '',
  114. orderDetailVisible: false,
  115. wrapperHeight: 0,
  116. params: { 'page': 0, 'per_page': 10 },
  117. loading: false, // 是否加载更多
  118. isMore: true, // 是否有更多
  119. order_list: false,
  120. }
  121. },
  122. mounted(){
  123. // #ifdef MP-WEIXIN
  124. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  125. // #endif
  126. this.wrapperHeight = uni.getSystemInfoSync().windowHeight - 180
  127. },
  128. computed:{
  129. fontSize(){
  130. return getFontSize()
  131. },
  132. ...mapState({
  133. user: state => state.member.info
  134. })
  135. },
  136. onLoad: function (option) {
  137. this.stateType=option.state ? option.state : ''
  138. this.loadMore()
  139. },
  140. methods:{
  141. closeDialog(){
  142. },
  143. confirmDialog(value){
  144. switch(this.dialog.condition){
  145. case 1:
  146. cancelOrder(this.dialog.data).then(res => {
  147. this.reload()
  148. }).catch(function (error) {
  149. uni.showToast({icon:'none',title: error.message})
  150. })
  151. break
  152. case 2:
  153. receiveOrder(this.dialog.data).then(res => {
  154. this.reload()
  155. }).catch(function (error) {
  156. uni.showToast({icon:'none',title: error.message})
  157. })
  158. break
  159. }
  160. },
  161. goNavigate(path,query=false){
  162. uni.navigateTo({url:path+(query?('?'+urlencode(query)):'')})
  163. },
  164. goBack(){uni.navigateBack({delta:1})},
  165. setOrderNavActive (index) {
  166. this.stateType = index
  167. this.getOrderList(true)
  168. },
  169. cancel (orderId) {
  170. this.dialog={condition:1,content:'确定要取消该订单吗?',data:orderId}
  171. this.$refs.confirm.open()
  172. },
  173. receive (orderId) {
  174. this.dialog={condition:2,content:'确定该订单已收货吗?',data:orderId}
  175. this.$refs.confirm.open()
  176. },
  177. loadMore () {
  178. this.loading = true
  179. this.params.page = ++this.params.page
  180. if (this.isMore) {
  181. this.loading = false
  182. this.getOrderList(false)
  183. }
  184. },
  185. reload () {
  186. // 重新加载数据
  187. this.params.page = 0
  188. this.isMore = true
  189. this.loading = false
  190. this.order_list = false
  191. this.loadMore()
  192. },
  193. getOrderList (ifReplace) {
  194. uni.showLoading({ title: '加载中' })
  195. if (ifReplace) {
  196. this.loading = false
  197. this.params.page = 1
  198. this.isMore = true
  199. }
  200. getOrderList(this.params, this.stateType, '').then(res => {
  201. uni.hideLoading()
  202. if (res.result.hasmore) {
  203. this.isMore = true
  204. } else {
  205. this.isMore = false
  206. }
  207. let tOrderList = res.result.order_list
  208. if (tOrderList) {
  209. if (ifReplace || !this.order_list) {
  210. this.order_list = tOrderList
  211. } else {
  212. this.order_list = this.order_list.concat(tOrderList)
  213. }
  214. }
  215. }).catch(function (error) {
  216. uni.hideLoading()
  217. uni.showToast({icon:'none',title: error.message})
  218. })
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="scss" scoped>
  224. .scroll-view-wrapper{display: flex;flex-direction: column;}
  225. .scroll-view{flex:1}
  226. .member-order-list {
  227. .order-header {
  228. height:2.2rem;
  229. .ul {
  230. list-style: none;
  231. width: auto;
  232. display: flex;
  233. justify-content: space-around;
  234. align-content: center;
  235. align-items: center;
  236. height: 100%;
  237. background: rgba(255, 255, 255, 1);
  238. border-bottom: 1px solid #e8eaed;
  239. .li {
  240. font-size:$subFontSize;
  241. color: #333;
  242. height: 100%;
  243. text-align: center;
  244. line-height:2.2rem;
  245. border-bottom:0.1rem solid transparent;
  246. &.active {
  247. color: $primaryColor;
  248. border-bottom-color: $primaryColor;
  249. }
  250. }
  251. }
  252. }
  253. .order-body {
  254. position:relative;
  255. .list {
  256. width: 100%;
  257. margin-top:0.5rem;
  258. .tips-body {
  259. height:2.2rem;
  260. background: rgba(255, 255, 255, 1);
  261. box-shadow: 0 0.5px 0 0 rgba(232, 234, 237, 1);
  262. display: flex;
  263. justify-content: space-between;
  264. padding: 0 0.75rem 0 0.5rem;
  265. .tips {
  266. font-size:$subFontSize;
  267. color: #333;
  268. line-height:2.2rem;
  269. }
  270. .statusTips {
  271. color: $primaryColor;
  272. }
  273. }
  274. .order-image {
  275. height: 4.55rem;
  276. background: rgba(250, 250, 250, 1);
  277. width: 100%;
  278. overflow:hidden;
  279. overflow-x: auto;
  280. white-space: nowrap;
  281. .goods_info{
  282. height:4rem;
  283. margin-bottom: .5rem;
  284. display: flex;
  285. align-items: center;
  286. padding-right: $pageSpace;
  287. .img-wrapper{
  288. width: 3rem;
  289. height: 3rem;
  290. margin: .85rem .6rem .5rem .3rem;
  291. .img{
  292. width: 3rem;
  293. height: 3rem;
  294. border-radius: 1px;
  295. }
  296. }
  297. .goods_name{
  298. white-space: normal;
  299. overflow: hidden;
  300. height: 2rem;
  301. width: 10rem;
  302. font-size: .7rem;
  303. }
  304. .goods_points{
  305. margin-left: auto;
  306. padding-right: .75rem;
  307. text-align: right;
  308. .points{
  309. font-size:$subFontSize;
  310. color: rgba(78, 84, 93, 1);
  311. }
  312. .num{
  313. font-size: .6rem;
  314. color: #999;
  315. padding-top: .3rem;
  316. }
  317. }
  318. }
  319. }
  320. .order_amount {
  321. font-size:$subFontSize;
  322. color: rgba(78, 84, 93, 1);
  323. line-height:2.2rem;
  324. height:2.2rem;
  325. background-color: #fff;
  326. padding: 0 0.75rem 0 0;
  327. border-bottom: 1px solid #e8eaed;
  328. box-sizing: border-box;
  329. text-align: right;
  330. overflow: hidden;
  331. text-overflow: ellipsis;
  332. white-space: nowrap;
  333. .order_amount_icon{
  334. font-size:$subFontSize;
  335. color: $primaryColor;
  336. }
  337. .i {
  338. font-size:$h1;
  339. color: $primaryColor;
  340. padding-left:0.25rem;
  341. font-style: normal;
  342. &.freight {
  343. color: #333;
  344. font-size:$fontSize;
  345. }
  346. }
  347. }
  348. }
  349. .loading-wrapper {
  350. text-align: center;
  351. .p {
  352. color: #c3c3c3;
  353. font-size:$fontSize;
  354. margin:0.5rem auto;
  355. }
  356. }
  357. }
  358. .mint-popup {
  359. width: 100%;
  360. height:12rem;
  361. }
  362. }
  363. .order-list-opratio{height: 2.2rem;display: flex;justify-content: flex-end;background: rgba(255, 255, 255, 1);border-radius: 0.1rem;}
  364. .order-list-opratio .button{width: 4.5rem;height: 1.5rem;font-size:$subFontSize;border-radius: 0.7rem;margin: 0.35rem 0.75rem 0.35rem 0;background-color: #fff;border: 1px solid #ccc;box-shadow: 0 3px 6px 0 rgba(0,0,0,.05);display:flex;align-items:center;justify-content:center;}
  365. .order-list-opratio .line_red{background-color: #fff;color: #f2270c;border: 1px solid #f2270c;box-shadow: 0 3px 6px 0 rgba(242,39,12,.1);}
  366. </style>