index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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. clearPage() {
  274. const that = this;
  275. that.$set(that, `list`, [])
  276. that.$set(that, `skip`, 0)
  277. that.$set(that, `limit`, 5)
  278. that.$set(that, `page`, 0)
  279. }
  280. }
  281. }
  282. </script>
  283. <style lang="scss">
  284. .main {
  285. display: flex;
  286. flex-direction: column;
  287. width: 100vw;
  288. height: 100vh;
  289. .one {
  290. padding: 2vw;
  291. input {
  292. padding: 2vw;
  293. background-color: var(--f1Color);
  294. font-size: var(--font14Size);
  295. border-radius: 5px;
  296. }
  297. }
  298. .two {
  299. position: relative;
  300. flex-grow: 1;
  301. background-color: var(--f9Color);
  302. .tabsList {
  303. position: relative;
  304. width: 100vw;
  305. height: 82vh;
  306. .list {
  307. background-color: #fff;
  308. margin: 0 2vw 2vw 2vw;
  309. padding: 2vw;
  310. .list_1 {
  311. margin: 0 0 1vw 0;
  312. display: flex;
  313. flex-direction: row;
  314. justify-content: space-between;
  315. }
  316. .list_2 {
  317. margin: 0 0 1vw 0;
  318. display: flex;
  319. .l {
  320. width: 20vw;
  321. .image {
  322. width: 100%;
  323. height: 20vw;
  324. border-radius: 5px;
  325. }
  326. }
  327. .c {
  328. width: 60vw;
  329. padding: 0 2vw;
  330. }
  331. .r {
  332. width: 15vw;
  333. text-align: right;
  334. }
  335. }
  336. .other {
  337. margin: 0 0 2vw 0;
  338. text-align: right;
  339. text {
  340. font-size: 14px;
  341. padding: 0 0 0 2vw;
  342. }
  343. }
  344. .btn {
  345. text-align: right;
  346. margin: 2vw 0 0 0;
  347. border-top: 1px solid #f1fff1;
  348. button {
  349. margin: 2vw 0 0 2vw;
  350. }
  351. }
  352. }
  353. }
  354. }
  355. }
  356. // .two {
  357. // position: relative;
  358. // flex-grow: 1;
  359. // background-color: var(--f9Color);
  360. // .two_1 {
  361. // background-color: var(--fffColor);
  362. // padding: 2vw;
  363. // display: flex;
  364. // flex-direction: row;
  365. // }
  366. // .two_2 {
  367. // display: flex;
  368. // flex-direction: column;
  369. // .list {
  370. // width: 100vw;
  371. // margin: 2vw 0 0 0;
  372. // background-color: var(--mainColor);
  373. // .list_1 {
  374. // display: flex;
  375. // flex-direction: row;
  376. // justify-content: space-between;
  377. // padding: 2vw;
  378. // .name {
  379. // font-size: var(--font14Size);
  380. // text {
  381. // margin: 0 1vw 0 0;
  382. // }
  383. // }
  384. // .status {
  385. // font-size: var(--font14Size);
  386. // color: var(--ff0Color);
  387. // }
  388. // }
  389. // .list_2 {
  390. // display: flex;
  391. // flex-direction: row;
  392. // justify-content: space-between;
  393. // padding: 2vw;
  394. // background-color: var(--f8Color);
  395. // .image {
  396. // width: 20vw;
  397. // height: 20vw;
  398. // margin: 0 2vw 0 0;
  399. // }
  400. // .other {
  401. // display: flex;
  402. // flex-direction: column;
  403. // flex-grow: 1;
  404. // .name {
  405. // font-size: var(--font14Size);
  406. // font-weight: bold;
  407. // margin: 0 0 2vw 0;
  408. // }
  409. // .other_1 {
  410. // font-size: var(--font12Size);
  411. // color: var(--f85Color);
  412. // }
  413. // }
  414. // .money {
  415. // font-size: var(--font12Size);
  416. // .num {
  417. // text-align: right;
  418. // }
  419. // }
  420. // }
  421. // .list_3 {
  422. // display: flex;
  423. // justify-content: flex-end;
  424. // padding: 2vw;
  425. // border-bottom: 0.5vw solid var(--f9Color);
  426. // font-size: var(--font12Size);
  427. // text {
  428. // margin: 0 1vw;
  429. // }
  430. // }
  431. // .list_4 {
  432. // padding: 2vw;
  433. // text-align: right;
  434. // button {
  435. // margin: 0 1vw 0 2vw;
  436. // }
  437. // }
  438. // }
  439. // }
  440. // }
  441. // }
  442. .scroll-view {
  443. position: absolute;
  444. top: 0;
  445. left: 0;
  446. right: 0;
  447. bottom: 0;
  448. .list-scroll-view {
  449. display: flex;
  450. flex-direction: column;
  451. }
  452. }
  453. </style>