OrderList.vue 10 KB

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