Browse Source

Merge branch 'master' of http://git.cc-lotus.info/pointToNetwork/point-app

guhongwei 2 năm trước cách đây
mục cha
commit
21e85449d0
7 tập tin đã thay đổi với 895 bổ sung606 xóa
  1. 38 0
      common/computed.js
  2. 12 16
      main.js
  3. 5 0
      package.json
  4. 6 0
      pages.json
  5. 615 585
      pagesHome/order/order.vue
  6. 11 5
      pagesMy/order/index.vue
  7. 208 0
      pagesMy/order/noService.vue

+ 38 - 0
common/computed.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Decimal from 'decimal.js';
+const toNumber = (num) => {
+  return new Decimal(num).toNumber();
+};
+const plus = (n1 = 0, n2 = 0) => {
+  const number1 = new Decimal(n1);
+  const number2 = new Decimal(n2);
+  let result = number1.add(number2);
+  result = result.toFixed(2, Decimal.ROUND_DOWN);
+  return toNumber(result);
+};
+const minus = (n1 = 0, n2 = 0) => {
+  const number1 = new Decimal(n1);
+  const number2 = new Decimal(n2);
+  let result = number1.minus(number2);
+  result = result.toFixed(2, Decimal.ROUND_DOWN);
+  return toNumber(result);
+};
+const multiply = (n1 = 0, n2 = 0) => {
+  const number1 = new Decimal(n1);
+  const number2 = new Decimal(n2);
+  let result = number1.mul(number2);
+  result = result.toFixed(2, Decimal.ROUND_DOWN);
+  return toNumber(result);
+};
+const divide = (n1 = 0, n2 = 0) => {
+  const number1 = new Decimal(n1);
+  const number2 = new Decimal(n2);
+  let result = number1.div(number2);
+  result = result.toFixed(2, Decimal.ROUND_DOWN);
+  return toNumber(result);
+};
+
+Vue.prototype.$plus = plus;
+Vue.prototype.$minus = minus;
+Vue.prototype.$multiply = multiply;
+Vue.prototype.$divide = divide;

+ 12 - 16
main.js

@@ -2,13 +2,10 @@
 import Vue from 'vue';
 import App from './App';
 // jwt解析
-import weappJwt from '@/common/weapp-jwt.js'
+import weappJwt from '@/common/weapp-jwt.js';
 Vue.prototype.$jwt = weappJwt;
 // requset请求
-import {
-	requestBase,
-	requestFile
-} from '@/common/api.js';
+import { requestBase, requestFile } from '@/common/api.js';
 Vue.prototype.$api = requestBase;
 Vue.prototype.$apifile = requestFile;
 // 配置文件
@@ -18,23 +15,22 @@ Vue.prototype.$config = config;
 import mobileFrame from '@/components/mobile-frame/index.vue';
 Vue.component('mobile-frame', mobileFrame);
 
-
 Vue.config.productionTip = false;
 App.mpType = 'app';
 const app = new Vue({
-	...App
-})
-app.$mount()
+  ...App,
+});
+app.$mount();
 // #endif
 
 // #ifdef VUE3
-import {
-	createSSRApp
-} from 'vue'
+import { createSSRApp } from 'vue';
 export function createApp() {
-	const app = createSSRApp(App)
-	return {
-		app
-	}
+  const app = createSSRApp(App);
+  return {
+    app,
+  };
 }
 // #endif
+
+import '@/common/computed.js';

+ 5 - 0
package.json

@@ -0,0 +1,5 @@
+{
+  "dependencies": {
+    "decimal.js": "^10.4.1"
+  }
+}

+ 6 - 0
pages.json

@@ -95,6 +95,12 @@
 						"navigationBarTitleText": "选择售后"
 					}
 				},
+				{
+					"path": "order/noService",
+					"style": {
+						"navigationBarTitleText": "选择售后"
+					}
+				},
 				{
 					"path": "discount/index",
 					"style": {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 615 - 585
pagesHome/order/order.vue


+ 11 - 5
pagesMy/order/index.vue

@@ -49,7 +49,7 @@
 									<view class="btn">
 										<button class="toCancel" v-if="item.status=='0'" type="default" size="mini" @click="toCancel(item)">取消订单</button>
 										<button class="toPay" v-if="item.status=='0'" type="default" size="mini" @click="toPay(item)">付款</button>
-										<button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @click="toAfter(item)">申请售后</button>
+										<button class="toAfter" v-if="item.status!='0'" type="default" size="mini" @click="toAfter(item)">申请售后</button>
 										<button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @click="toAfter(item)">申请退款</button>
 									</view>
 								</view>
@@ -92,7 +92,7 @@
 									<view class="btn">
 										<button class="toCancel" v-if="item.status=='0'" type="default" size="mini" @click="toCancel(item)">取消订单</button>
 										<button class="toPay" v-if="item.status=='0'" type="default" size="mini" @click="toPay(item)">付款</button>
-										<button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @click="toAfter(item)">申请售后</button>
+										<button class="toAfter" v-if="item.status!='0'" type="default" size="mini" @click="toAfter(item)">申请售后</button>
 										<button class="toAfter" v-if="item.status=='3'" type="default" size="mini" @click="toAfter(item)">申请退款</button>
 									</view>
 								</view>
@@ -323,9 +323,15 @@
 			},
 			// 申请售后 申请退款
 			toAfter(e) {
-				uni.navigateTo({
-					url: `/pagesMy/order/service?id=${e._id}`
-				})
+				if(e.status=='3'){
+					uni.navigateTo({
+						url: `/pagesMy/order/service?id=${e._id}`
+					})
+				}else{
+					uni.navigateTo({
+						url: `/pagesMy/order/noService?id=${e._id}`
+					})
+				}
 			},
 			// 选择选项卡
 			tabsChange(e) {

+ 208 - 0
pagesMy/order/noService.vue

@@ -0,0 +1,208 @@
+<template>
+	<mobile-frame>
+		<view class="main">
+			<view class="one">
+				<view class="list" v-for="(item,index) in goodsList" :key="index" >
+					<view class="list_1">
+						<text>退款商品</text>
+					</view>
+					<view class="list_2">
+						<view class="l">
+							<image class="image"
+								:src="item.goods.file&&item.goods.file.length>0?item.goods.file[0].url:''" mode="">
+							</image>
+						</view>
+						<view class="c">
+							<view class="name">
+								{{item.name}}
+							</view>
+						</view>
+						<view class="r">
+							<view class="price">
+								¥{{item.sell_money}}
+							</view>
+							<view class="num">
+								×{{item.buy_num}}
+							</view>
+						</view>
+					</view>
+				</view>
+			</view>
+			<view class="two">
+				<uni-forms ref="form" :rules="rules" :model="form" label-width="auto">
+					<uni-forms-item label="申请售后理由" name="desc">
+						<uni-easyinput type="textarea" v-model="form.desc" placeholder="请输入申请售后描述" />
+					</uni-forms-item>
+					<view class="btn">
+						<button type="primary" size="mini" @click="onSubmit('form')">提交保存</button>
+					</view>
+				</uni-forms>
+			</view>
+		</view>
+	</mobile-frame>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				id: '',
+				user: {},
+				form: {},
+				// 退货商品
+				goodsList: [],
+				icon: [],
+				rules: {
+					desc: {
+						rules: [{
+							required: true,
+							errorMessage: '请输入申请售后描述',
+						}]
+					},
+				},
+			};
+		},
+		onLoad: async function(e) {
+			const that = this;
+			that.$set(that, `id`, e && e.id || '');
+			// 监听用户登录
+			that.watchLogin();
+		},
+		methods: {
+			// 提交保存
+			async onSubmit(ref) {
+				const that = this;
+				that.$refs[ref].validate().then(async params => {
+					params.order_detail = that.id
+					const arr = await that.$api(`/afterSale/orderCancel`, 'POST', params);
+					if (arr.errcode == '0') {
+						uni.showToast({
+							title: `申请售后成功`,
+							icon: 'success',
+						});
+						uni.navigateBack({
+							detail: 1
+						})
+					} else {
+						uni.showToast({
+							title: arr.errmsg,
+							icon: 'none',
+						})
+					}
+				})
+			},
+			// 监听用户是否登录
+			watchLogin() {
+				const that = this;
+				uni.getStorage({
+					key: 'token',
+					success: async function(res) {
+						let user = that.$jwt(res.data);
+						if (user) {
+							that.$set(that, `user`, user);
+							if (that.id) {
+								let arr = await that.$api(`/orderDetail/${that.id}`, 'GET')
+								if (arr.errcode == '0') {
+									that.$set(that, `goodsList`, arr.data.goods)
+								}
+							}
+						}
+					},
+					fail: function(err) {
+						uni.reLaunch({
+							url: '/pages/login/index'
+						})
+					}
+				})
+			},
+		}
+	}
+</script>
+
+<style lang="scss">
+	.main {
+		.one {
+			.list {
+				margin: 2vw;
+				padding: 2vw;
+				border-radius: 2vw;
+				border: 1px solid #3333;
+
+				.list_1 {
+					margin: 0 0 1vw 0;
+					display: flex;
+					flex-direction: row;
+					justify-content: space-between;
+					font-size: var(--font14Size);
+					font-weight: bold;
+				}
+
+				.list_2 {
+					margin: 0 0 1vw 0;
+					display: flex;
+
+					.l {
+						width: 20vw;
+
+						.image {
+							width: 100%;
+							height: 20vw;
+							border-radius: 5px;
+
+						}
+					}
+
+					.c {
+						width: 50vw;
+						padding: 0 2vw;
+					}
+
+					.r {
+						width: 25vw;
+						text-align: right;
+					}
+				}
+
+				.other {
+					margin: 0 0 2vw 0;
+					text-align: right;
+
+					text {
+						font-size: 14px;
+
+						padding: 0 0 0 2vw;
+					}
+				}
+
+				.btn {
+					text-align: right;
+					margin: 2vw 0 0 0;
+					border-top: 1px solid #f1fff1;
+
+					button {
+						margin: 2vw 0 0 2vw;
+					}
+				}
+			}
+		}
+
+		.two {
+			padding: 2vw;
+			.btn {
+				text-align: center;
+
+				button {
+					width: 30%;
+					font-size: 14px;
+					background-color: var(--f35BColor);
+				}
+			}
+		}
+	}
+
+	.uni-forms-item {
+		margin-bottom: 6vw !important;
+		display: flex;
+		flex-direction: row;
+	}
+</style>