index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  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: '0',
  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. const that = this;
  236. uni.showModal({
  237. title: '提示',
  238. content: '确定申请售后吗?',
  239. success: async function(res) {
  240. if (res.confirm) {
  241. const arr = await that.$api(`/order/${e._id}`, 'POST', {
  242. status: '-3'
  243. });
  244. if (arr.errcode == '0') {
  245. uni.showToast({
  246. title: '申请售后成功',
  247. icon: 'none'
  248. })
  249. that.clearPage();
  250. that.search();
  251. } else {
  252. uni.showToast({
  253. title: arr.errmsg,
  254. icon: 'none'
  255. })
  256. }
  257. }
  258. }
  259. });
  260. },
  261. // 申请退款
  262. toRefund(e) {
  263. console.log(e);
  264. },
  265. // 选择选项卡
  266. tabsChange(e) {
  267. const that = this;
  268. that.$set(that.tabs, `active`, e.active)
  269. that.$set(that, `status`, e.active);
  270. that.search()
  271. }
  272. }
  273. }
  274. </script>
  275. <style lang="scss">
  276. .main {
  277. display: flex;
  278. flex-direction: column;
  279. width: 100vw;
  280. height: 100vh;
  281. .one {
  282. padding: 2vw;
  283. input {
  284. padding: 2vw;
  285. background-color: var(--f1Color);
  286. font-size: var(--font14Size);
  287. border-radius: 5px;
  288. }
  289. }
  290. .two {
  291. position: relative;
  292. flex-grow: 1;
  293. background-color: var(--f9Color);
  294. .tabsList {
  295. position: relative;
  296. width: 100vw;
  297. height: 82vh;
  298. .list {
  299. background-color: #fff;
  300. margin: 0 2vw 2vw 2vw;
  301. padding: 2vw;
  302. .list_1 {
  303. margin: 0 0 1vw 0;
  304. display: flex;
  305. flex-direction: row;
  306. justify-content: space-between;
  307. }
  308. .list_2 {
  309. margin: 0 0 1vw 0;
  310. display: flex;
  311. .l {
  312. width: 20vw;
  313. .image {
  314. width: 100%;
  315. height: 20vw;
  316. border-radius: 5px;
  317. }
  318. }
  319. .c {
  320. width: 60vw;
  321. padding: 0 2vw;
  322. }
  323. .r {
  324. width: 15vw;
  325. text-align: right;
  326. }
  327. }
  328. .other {
  329. margin: 0 0 2vw 0;
  330. text-align: right;
  331. text {
  332. font-size: 14px;
  333. padding: 0 0 0 2vw;
  334. }
  335. }
  336. .btn {
  337. text-align: right;
  338. margin: 2vw 0 0 0;
  339. border-top: 1px solid #f1fff1;
  340. button {
  341. margin: 2vw 0 0 2vw;
  342. }
  343. }
  344. }
  345. }
  346. }
  347. }
  348. // .two {
  349. // position: relative;
  350. // flex-grow: 1;
  351. // background-color: var(--f9Color);
  352. // .two_1 {
  353. // background-color: var(--fffColor);
  354. // padding: 2vw;
  355. // display: flex;
  356. // flex-direction: row;
  357. // }
  358. // .two_2 {
  359. // display: flex;
  360. // flex-direction: column;
  361. // .list {
  362. // width: 100vw;
  363. // margin: 2vw 0 0 0;
  364. // background-color: var(--mainColor);
  365. // .list_1 {
  366. // display: flex;
  367. // flex-direction: row;
  368. // justify-content: space-between;
  369. // padding: 2vw;
  370. // .name {
  371. // font-size: var(--font14Size);
  372. // text {
  373. // margin: 0 1vw 0 0;
  374. // }
  375. // }
  376. // .status {
  377. // font-size: var(--font14Size);
  378. // color: var(--ff0Color);
  379. // }
  380. // }
  381. // .list_2 {
  382. // display: flex;
  383. // flex-direction: row;
  384. // justify-content: space-between;
  385. // padding: 2vw;
  386. // background-color: var(--f8Color);
  387. // .image {
  388. // width: 20vw;
  389. // height: 20vw;
  390. // margin: 0 2vw 0 0;
  391. // }
  392. // .other {
  393. // display: flex;
  394. // flex-direction: column;
  395. // flex-grow: 1;
  396. // .name {
  397. // font-size: var(--font14Size);
  398. // font-weight: bold;
  399. // margin: 0 0 2vw 0;
  400. // }
  401. // .other_1 {
  402. // font-size: var(--font12Size);
  403. // color: var(--f85Color);
  404. // }
  405. // }
  406. // .money {
  407. // font-size: var(--font12Size);
  408. // .num {
  409. // text-align: right;
  410. // }
  411. // }
  412. // }
  413. // .list_3 {
  414. // display: flex;
  415. // justify-content: flex-end;
  416. // padding: 2vw;
  417. // border-bottom: 0.5vw solid var(--f9Color);
  418. // font-size: var(--font12Size);
  419. // text {
  420. // margin: 0 1vw;
  421. // }
  422. // }
  423. // .list_4 {
  424. // padding: 2vw;
  425. // text-align: right;
  426. // button {
  427. // margin: 0 1vw 0 2vw;
  428. // }
  429. // }
  430. // }
  431. // }
  432. // }
  433. // }
  434. .scroll-view {
  435. position: absolute;
  436. top: 0;
  437. left: 0;
  438. right: 0;
  439. bottom: 0;
  440. .list-scroll-view {
  441. display: flex;
  442. flex-direction: column;
  443. }
  444. }
  445. </style>