index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索商品">
  6. </view>
  7. <view class="two">
  8. <tabs :tabs="tabs" @tabsChange="tabsChange">
  9. <view class="tabsList">
  10. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  11. <view class="list-scroll-view">
  12. <view class="list" v-for="(item,index) in list" :key="index">
  13. <view class="list_1">
  14. <view class="l">
  15. <text class="iconfont icon-shangdian"></text>
  16. <text>{{item.shop}}</text>
  17. </view>
  18. <view class="r">
  19. {{item.status=='0'?'待付款':'已付款'}}
  20. </view>
  21. </view>
  22. <view class="list_2">
  23. <view class="l">
  24. <image class="image" :src="item.url&&item.url.length>0?item.url[0].url:''"
  25. mode=""></image>
  26. </view>
  27. <view class="c">
  28. <view class="name">
  29. {{item.name}}
  30. </view>
  31. </view>
  32. <view class="r">
  33. <view class="price">
  34. ¥{{item.price}}
  35. </view>
  36. <view class="num">
  37. ×{{item.buy_num}}
  38. </view>
  39. </view>
  40. </view>
  41. <view class="other">
  42. <text>共{{item.market_num}}件商品</text>
  43. <text>总价¥{{item.money}}</text>
  44. </view>
  45. <view class="btn">
  46. <button v-if="item.status=='0'" type="default" @click="toCancel(item)"
  47. size="mini">取消订单</button>
  48. <button v-if="item.status=='0'" type="default" @click="toPay(item)"
  49. size="mini">付款</button>
  50. <button v-if="item.status=='3'" type="default" @click="toAfter(item)"
  51. size="mini">申请售后</button>
  52. <button v-if="item.status=='3'" type="default" @click="toRefund(item)"
  53. size="mini">申请退款</button>
  54. </view>
  55. </view>
  56. </view>
  57. </scroll-view>
  58. </view>
  59. </tabs>
  60. </view>
  61. </view>
  62. </mobile-frame>
  63. </template>
  64. <script>
  65. import tabs from '@/components/tabs/index.vue';
  66. export default {
  67. components: {
  68. tabs
  69. },
  70. data() {
  71. return {
  72. user: {},
  73. status: '',
  74. searchInfo: {},
  75. tabs: {
  76. active: '-0',
  77. menu: [ //菜单列表
  78. {
  79. title: '全部订单',
  80. active: '-0'
  81. },
  82. {
  83. title: '待付款',
  84. active: '0'
  85. },
  86. {
  87. title: '待发货',
  88. active: '1'
  89. },
  90. {
  91. title: '待收货',
  92. active: '2'
  93. },
  94. {
  95. title: '已收货',
  96. active: '3'
  97. }
  98. ]
  99. },
  100. list: [ //订单列表
  101. {
  102. shop: '官方自营店',
  103. status: '3',
  104. url: [{
  105. name: "20220928155634.jpg",
  106. uri: "/files/point/20220928155634.jpg",
  107. url: "https://broadcast.waityou24.cn/files/point/20220928155634.jpg"
  108. }],
  109. name: '饮用水',
  110. price: 58,
  111. buy_num: 1,
  112. market_num: 1,
  113. money: 58
  114. }
  115. ]
  116. };
  117. },
  118. onLoad: function(e) {
  119. const that = this;
  120. that.$set(that, `status`, e.status);
  121. // 监听用户是否登录
  122. that.watchLogin();
  123. },
  124. onShow: function() {},
  125. methods: {
  126. // 监听用户是否登录
  127. watchLogin() {
  128. const that = this;
  129. uni.getStorage({
  130. key: 'token',
  131. success: function(res) {
  132. let user = that.$jwt(res.data);
  133. if (user) that.$set(that, `user`, user);
  134. that.$set(that.tabs, `active`, that.status);
  135. that.search();
  136. },
  137. fail: function(err) {
  138. uni.navigateTo({
  139. url: `/pages/login/index`
  140. })
  141. }
  142. });
  143. },
  144. // 查询列表
  145. async search() {
  146. const that = this;
  147. let user = that.user;
  148. let status = that.status;
  149. console.log(status);
  150. },
  151. // 分页
  152. toPage(e) {
  153. },
  154. // 输入框
  155. toInput(e) {
  156. const that = this;
  157. that.$set(that.searchInfo, `name`, e.detail.value)
  158. },
  159. // 取消订单
  160. toCancel(e) {
  161. const that = this;
  162. uni.showModal({
  163. title: '提示',
  164. content: '确定取消订单吗?',
  165. success: async function(res) {
  166. if (res.confirm) {
  167. const arr = await that.$api(`/order/${e._id}`, 'POST', {
  168. status: '-1'
  169. });
  170. if (arr.errcode == '0') {
  171. uni.showToast({
  172. title: '取消订单成功',
  173. icon: 'none'
  174. })
  175. that.clearPage();
  176. that.search();
  177. } else {
  178. uni.showToast({
  179. title: arr.errmsg,
  180. icon: 'none'
  181. })
  182. }
  183. }
  184. }
  185. });
  186. },
  187. // 付款
  188. toPay(e) {
  189. uni.getStorage({
  190. key: 'system',
  191. success: async function(res) {
  192. // 微信小程序支付
  193. if (res.data.uniPlatform == "mp-weixin") {
  194. const res = await that.$api('/pay/toPayOrder', 'POST', {
  195. order_id: e,
  196. type: '0'
  197. })
  198. console.log(res);
  199. uni.requestPayment({
  200. "provider": "wxpay",
  201. ...res.data,
  202. success(res) {
  203. console.log('in success');
  204. console.log(res)
  205. },
  206. fail(e) {
  207. console.log('in fail');
  208. console.log(e)
  209. }
  210. })
  211. } else if (res.data.uniPlatform == "app") {
  212. // app支付
  213. uni.requestPayment({
  214. provider: 'alipay',
  215. orderInfo: 'orderInfo', //微信、支付宝订单数据 【注意微信的订单信息,键值应该全部是小写,不能采用驼峰命名】
  216. success: function(res) {
  217. console.log('success:' + JSON.stringify(res));
  218. },
  219. fail: function(err) {
  220. console.log('fail:' + JSON.stringify(err));
  221. }
  222. });
  223. } else {
  224. uni.showToast({
  225. title: `平台不支持支付`,
  226. icon: 'none'
  227. })
  228. }
  229. },
  230. fail: function(err) {}
  231. })
  232. },
  233. // 申请售后
  234. toAfter(e) {
  235. uni.navigateTo({
  236. url: `/pagesMy/order/service?id=${e._id}`
  237. })
  238. },
  239. // 申请退款
  240. toRefund(e) {
  241. console.log(e);
  242. },
  243. // 选择选项卡
  244. tabsChange(e) {
  245. const that = this;
  246. that.$set(that.tabs, `active`, e.active)
  247. that.$set(that, `status`, e.active);
  248. that.search()
  249. },
  250. // 清空列表
  251. clearPage() {
  252. const that = this;
  253. that.$set(that, `list`, [])
  254. that.$set(that, `skip`, 0)
  255. that.$set(that, `limit`, 5)
  256. that.$set(that, `page`, 0)
  257. }
  258. }
  259. }
  260. </script>
  261. <style lang="scss">
  262. .main {
  263. display: flex;
  264. flex-direction: column;
  265. width: 100vw;
  266. height: 100vh;
  267. .one {
  268. padding: 2vw;
  269. input {
  270. padding: 2vw;
  271. background-color: var(--f1Color);
  272. font-size: var(--font14Size);
  273. border-radius: 5px;
  274. }
  275. }
  276. .two {
  277. position: relative;
  278. flex-grow: 1;
  279. background-color: var(--f9Color);
  280. .tabsList {
  281. position: relative;
  282. width: 100vw;
  283. height: 82vh;
  284. .list {
  285. background-color: #fff;
  286. margin: 0 2vw 2vw 2vw;
  287. padding: 2vw;
  288. .list_1 {
  289. margin: 0 0 1vw 0;
  290. display: flex;
  291. flex-direction: row;
  292. justify-content: space-between;
  293. }
  294. .list_2 {
  295. margin: 0 0 1vw 0;
  296. display: flex;
  297. .l {
  298. width: 20vw;
  299. .image {
  300. width: 100%;
  301. height: 20vw;
  302. border-radius: 5px;
  303. }
  304. }
  305. .c {
  306. width: 60vw;
  307. padding: 0 2vw;
  308. }
  309. .r {
  310. width: 15vw;
  311. text-align: right;
  312. }
  313. }
  314. .other {
  315. margin: 0 0 2vw 0;
  316. text-align: right;
  317. text {
  318. font-size: 14px;
  319. padding: 0 0 0 2vw;
  320. }
  321. }
  322. .btn {
  323. text-align: right;
  324. margin: 2vw 0 0 0;
  325. border-top: 1px solid #f1fff1;
  326. button {
  327. margin: 2vw 0 0 2vw;
  328. }
  329. }
  330. }
  331. }
  332. }
  333. }
  334. // .two {
  335. // position: relative;
  336. // flex-grow: 1;
  337. // background-color: var(--f9Color);
  338. // .two_1 {
  339. // background-color: var(--fffColor);
  340. // padding: 2vw;
  341. // display: flex;
  342. // flex-direction: row;
  343. // }
  344. // .two_2 {
  345. // display: flex;
  346. // flex-direction: column;
  347. // .list {
  348. // width: 100vw;
  349. // margin: 2vw 0 0 0;
  350. // background-color: var(--mainColor);
  351. // .list_1 {
  352. // display: flex;
  353. // flex-direction: row;
  354. // justify-content: space-between;
  355. // padding: 2vw;
  356. // .name {
  357. // font-size: var(--font14Size);
  358. // text {
  359. // margin: 0 1vw 0 0;
  360. // }
  361. // }
  362. // .status {
  363. // font-size: var(--font14Size);
  364. // color: var(--ff0Color);
  365. // }
  366. // }
  367. // .list_2 {
  368. // display: flex;
  369. // flex-direction: row;
  370. // justify-content: space-between;
  371. // padding: 2vw;
  372. // background-color: var(--f8Color);
  373. // .image {
  374. // width: 20vw;
  375. // height: 20vw;
  376. // margin: 0 2vw 0 0;
  377. // }
  378. // .other {
  379. // display: flex;
  380. // flex-direction: column;
  381. // flex-grow: 1;
  382. // .name {
  383. // font-size: var(--font14Size);
  384. // font-weight: bold;
  385. // margin: 0 0 2vw 0;
  386. // }
  387. // .other_1 {
  388. // font-size: var(--font12Size);
  389. // color: var(--f85Color);
  390. // }
  391. // }
  392. // .money {
  393. // font-size: var(--font12Size);
  394. // .num {
  395. // text-align: right;
  396. // }
  397. // }
  398. // }
  399. // .list_3 {
  400. // display: flex;
  401. // justify-content: flex-end;
  402. // padding: 2vw;
  403. // border-bottom: 0.5vw solid var(--f9Color);
  404. // font-size: var(--font12Size);
  405. // text {
  406. // margin: 0 1vw;
  407. // }
  408. // }
  409. // .list_4 {
  410. // padding: 2vw;
  411. // text-align: right;
  412. // button {
  413. // margin: 0 1vw 0 2vw;
  414. // }
  415. // }
  416. // }
  417. // }
  418. // }
  419. // }
  420. .scroll-view {
  421. position: absolute;
  422. top: 0;
  423. left: 0;
  424. right: 0;
  425. bottom: 0;
  426. .list-scroll-view {
  427. display: flex;
  428. flex-direction: column;
  429. }
  430. }
  431. </style>