123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634 |
- <template>
- <mobile-frame>
- <view class="main">
- <view class="one" v-if="status!='-3'">
- <view class="one_1">
- <text>售后商品</text>
- </view>
- <view class="one_2">
- <view v-for="(item,index) in info.goods" :key="index">
- <view class="set_name" v-if="item.is_set=='0'">
- <text class="set">套装</text> {{item.name}}
- </view>
- <view class="list" v-if="item.is_set=='0'" v-for="(tag,indexx) in item.goods" :key="indexx">
- <view class="list_1">
- <image class="image"
- :src="tag.goods.file&&tag.goods.file.length>0?tag.goods.file[0].url:''" mode="">
- </image>
- </view>
- <view class="list_2">
- <view class="name">
- {{tag.goods_name}}
- </view>
- <view class="other_1">
- <text>规格:</text>
- <text>{{tag.spec_name}}</text>
- </view>
- <view class="other_1">
- <text>数量:</text>
- <text>×{{tag.set_num}}</text>
- </view>
- </view>
- </view>
- <view class="set" v-if="item.is_set=='0'">
- <view class="set_1">套装价:¥{{item.sell_money}}</view>
- <view class="set_2">数量:×{{item.buy_num}}</view>
- </view>
- <view class="list" v-else>
- <view class="list_1">
- <image class="image"
- :src="item.goods.file&&item.goods.file.length>0?item.goods.file[0].url:''" mode="">
- </image>
- </view>
- <view class="list_2">
- <view class="name">
- {{item.goods_name}}
- </view>
- <view class="other_1">
- <text>规格:</text>
- <text>{{item.name}}</text>
- </view>
- <view class="other_1">
- <text>金额:</text>
- <text
- class="money">¥{{info.type=='0'?item.price||item.sell_money:item.group_config.money}}</text>
- </view>
- <view class="other_1">
- <text>数量:</text>
- <text>×{{item.buy_num}}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="two">
- <view class="two_1" v-if="status=='3'||status=='-3'">
- <uni-forms ref="thrform" :rules="thrrules" :model="thrform" label-width="auto">
- <uni-forms-item label="售后商品" name="goods"
- v-if="status!='-3'&&goodsList.length>0&&!thrform.set_id">
- <picker class="picker" mode="selector" :range="goodsList" @change="goodsChange"
- range-key="goods_name">
- <view>{{thrform.goods_name||'请选择退款商品'}}</view>
- </picker>
- </uni-forms-item>
- <uni-forms-item label="售后套装" name="set_id"
- v-if="status!='-3'&&!thrform.goods_name&&setList.length>0">
- <picker class="picker" mode="selector" :range="setList" @change="setChange"
- range-key="name">
- <view>{{thrform.set_name||'请选择退款套装'}}</view>
- </picker>
- </uni-forms-item>
- <uni-forms-item label="售后套装商品" name="goods" v-if="status!='-3'&&thrform.set_name">
- <picker class="picker" mode="selector" :range="setgoodsList" @change="setgoodsChange"
- range-key="goods_name">
- <view>{{thrform.goods_name||'请选择退款套装商品'}}</view>
- </picker>
- </uni-forms-item>
- <uni-forms-item label="售后类型" name="type">
- <picker class="picker" mode="selector" :range="typeList" @change="typeChange"
- range-key="label">
- <view>{{thrform.type_name||'请选择售后类型'}}</view>
- </picker>
- </uni-forms-item>
- <uni-forms-item label="退款金额" name="money" v-if="thrform.type=='1'||thrform.type=='2'">
- <uni-easyinput type="digit" v-model="thrform.money" @input="toMoney"
- placeholder="请输入退款金额" />
- <view class="money">
- 最大退款金额不能超过 <text>{{moneyInfo.payTotal||0}}</text>,<text @tap="toAll">全部退款</text>
- </view>
- </uni-forms-item>
- <uni-forms-item label="申请理由" name="reason">
- <picker class="picker" mode="selector" :range="reasonList" @change="reasonChange"
- range-key="label">
- <view>{{thrform.reason_name||'请选择申请理由'}}</view>
- </picker>
- </uni-forms-item>
- <uni-forms-item label="售后描述" name="desc">
- <uni-easyinput type="textarea" v-model="thrform.desc" placeholder="请输入售后描述" />
- </uni-forms-item>
- <uni-forms-item label="附件" name="file">
- <upload :list="thrform.file" name="file" :count="1" @uplSuc="uplSuc" @uplDel="uplDel">
- </upload>
- </uni-forms-item>
- <view class="btn">
- <button type="primary" size="mini" @click="onSubmit('thrform')">提交保存</button>
- </view>
- </uni-forms>
- </view>
- <view class="two_2" v-else>
- <uni-forms ref="form" :rules="rules" :model="form" label-width="auto">
- <uni-forms-item label="申请描述" name="desc">
- <uni-easyinput type="textarea" autoHeight v-model="form.desc" placeholder="请输入申请描述" />
- </uni-forms-item>
- <view class="btn">
- <button type="default" size="mini" @click="onSubmit('form')">提交保存</button>
- </view>
- </uni-forms>
- </view>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- import upload from '../components/upload/index.vue';
- export default {
- components: {
- upload
- },
- data() {
- return {
- id: '',
- status: '',
- // 用户信息
- user: {},
- // 信息详情
- info: {},
- // 仅退款
- form: {},
- rules: {
- desc: {
- rules: [{
- required: true,
- errorMessage: '请输入申请描述',
- }]
- },
- },
- // 已收到货
- thrform: {
- file: []
- },
- // 最大退款数
- moneyInfo: {},
- thrrules: {
- type: {
- rules: [{
- required: true,
- errorMessage: '请选择售后类型',
- }]
- },
- goods: {
- rules: [{
- required: true,
- errorMessage: '请选择退款商品',
- }]
- },
- reason: {
- rules: [{
- required: true,
- errorMessage: '请选择申请理由',
- }]
- },
- },
- // 售后类型
- typeList: [],
- // 申请理由
- reasonList: [],
- // 正常商品
- goodsList: [],
- // 套装
- setList: [],
- // 套装商品
- setgoodsList: [],
- };
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `id`, e && e.id || '');
- that.$set(that, `status`, e && e.status || '');
- // 查询其他信息
- await that.searchOther();
- // 监听用户登录
- await that.watchLogin();
- },
- methods: {
- watchLogin() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: function(res) {
- let user = that.$jwt(res.data);
- if (user) {
- that.$set(that, `user`, user);
- that.search();
- }
- },
- fail: function() {
- uni.navigateTo({
- url: `/pages/login/index`
- })
- }
- })
- },
- async search() {
- const that = this;
- let res;
- if (that.status != '-3') {
- res = await that.$api(`/orderDetail/${that.id}`, 'GET')
- if (res.errcode == '0') {
- for (let val of res.data.goods) val.goods_name = val.goods.name;
- that.$set(that, `info`, res.data)
- let goodsList = res.data.goods.filter(i => i.is_set != '0')
- that.$set(that, `goodsList`, goodsList)
- let setList = res.data.goods.filter(i => i.is_set == '0')
- that.$set(that, `setList`, setList)
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- } else {
- res = await that.$api(`/groupOrder/userView/${that.id}`, 'GET', {}, 'group')
- if (res.errcode == '0') {
- that.$set(that.thrform, `goods`, res.data.goods._id);
- that.$set(that, `info`, res.data)
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- }
- },
- // 售后请求
- // 已收到货
- goodsChange(e) {
- const that = this;
- let data = that.goodsList[e.detail.value];
- if (data) that.$set(that.info, `goods`, [data])
- that.$set(that.thrform, `goods`, data._id);
- that.$set(that.thrform, `goods_name`, data.goods_name);
- },
- // 套装
- setChange(e) {
- const that = this;
- let data = that.setList[e.detail.value];
- if (data) {
- that.$set(that, `setgoodsList`, data.goods)
- that.$set(that.info, `goods`, [data])
- }
- that.$set(that.thrform, `set_id`, data._id);
- that.$set(that.thrform, `set_name`, data.name);
- },
- // 套装商品
- setgoodsChange(e) {
- const that = this;
- let data = that.setgoodsList[e.detail.value];
- that.$set(that.thrform, `goods`, data.spec._id);
- that.$set(that.thrform, `goods_name`, data.goods_name);
- },
- // 选择售后类型
- async typeChange(e) {
- const that = this;
- let thrform = that.thrform;
- let data = that.typeList[e.detail.value];
- if (data) {
- that.$set(that.thrform, `type`, data.value);
- that.$set(that.thrform, `type_name`, data.label);
- }
- if (that.status != '-3') {
- if (data.value != '3') {
- if (thrform.goods) {
- let obj = {
- order_detail: that.id,
- }
- if (thrform.set_id) obj.goods_id = thrform.set_id;
- else obj.goods_id = thrform.goods;
- const arr = await that.$api(`/afterSale/cgfr`, 'POST', obj);
- if (arr.errcode == '0') {
- that.$set(that, `moneyInfo`, arr.data);
- } else {
- uni.showToast({
- title: arr.errmsg,
- icon: 'none',
- })
- }
- } else {
- uni.showToast({
- title: '缺少商品信息',
- icon: 'none'
- })
- }
- }
- } else {
- that.$set(that.moneyInfo, `payTotal`, that.info.pay);
- }
- },
- // 选择申请理由
- reasonChange(e) {
- const that = this;
- let data = that.reasonList[e.detail.value];
- if (data) {
- that.$set(that.thrform, `reason`, data.value);
- that.$set(that.thrform, `reason_name`, data.label);
- }
- },
- // 退款金额
- toMoney(value) {
- const that = this;
- let money = that.moneyInfo.payTotal;
- if (parseFloat(value) > parseFloat(money)) {
- uni.showToast({
- title: '输入金额不能超过实际支付金额',
- icon: 'none'
- })
- }
- },
- // 图片上传
- uplSuc(e) {
- const that = this;
- that.$set(that.thrform, `${e.name}`, [...that.thrform[e.name], e.data]);
- },
- // 图片删除
- uplDel(e) {
- const that = this;
- let data = that.thrform[e.name];
- let arr = data.filter((i, index) => index != e.data.index);
- that.$set(that.thrform, `${e.name}`, arr)
- },
- // 全部提现
- toAll() {
- const that = this;
- that.$set(that.thrform, `money`, that.moneyInfo.payTotal)
- },
- // 提交保存
- async onSubmit(ref) {
- const that = this;
- let status = that.status;
- that.$refs[ref].validate().then(async params => {
- // 判断是否团长提现完成 如果提现成功不能退款 过了规定日期
- if (that.thrform.set_id) params.set_id = that.thrform.set_id;
- let arr;
- if (that.status != '-3') arr = await that.$api(`/afterSale/canRefund/${that.id}`,
- 'GET');
- else arr = await that.$api(`/groupAfterSale/canRefund/${that.id}`,
- 'GET', {}, 'group');
- if (arr.errcode == '0') {
- if (arr.data == true) {
- if (status == '3') that.Receip(params)
- else that.orderCancel(params)
- } else {
- uni.showToast({
- title: '该商品时间超时不允许退款或退货',
- icon: 'none'
- })
- }
- } else {
- uni.showToast({
- title: arr.errmsg,
- icon: 'none'
- })
- }
- })
- },
- // 已收到货
- async Receip(e) {
- const that = this;
- e.file = that.thrform.file;
- let money = that.moneyInfo.payTotal;
- let res;
- if (e.type != '3') {
- if (e.money) {
- if (parseFloat(e.money) > parseFloat(money)) {
- uni.showToast({
- title: '输入金额不能超过实际支付金额',
- icon: 'none'
- })
- } else {
- if (that.status == '-3') {
- e.order = that.id;
- res = await that.$api(`/groupAfterSale`, 'POST', e, 'group')
- } else {
- e.order_detail = that.id;
- res = await that.$api(`/afterSale`, 'POST', e)
- }
- }
- } else {
- uni.showToast({
- title: `请输入退款金额`,
- icon: 'none',
- });
- }
- } else {
- if (that.status == '-3') {
- e.order = that.id;
- res = await that.$api(`/groupAfterSale`, 'POST', e, 'group')
- } else {
- e.order_detail = that.id;
- res = await that.$api(`/afterSale`, 'POST', e)
- }
- }
- if (res.errcode == '0') {
- uni.showToast({
- title: '申请售后完成',
- icon: 'none'
- })
- uni.navigateBack({
- detail: 1
- })
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- },
- // 未收到货
- async orderCancel(e) {
- const that = this;
- let res;
- if (that.status == '-3') {
- e.order = that.id;
- res = await that.$api(`/groupAfterSale`, 'POST', e, 'group')
- } else {
- e.order_detail = that.id;
- res = await that.$api(`/afterSale`, 'POST', e)
- }
- if (res.errcode == '0') {
- uni.showToast({
- title: `申请售后成功`,
- icon: 'success',
- });
- uni.navigateBack({
- detail: 1
- })
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none',
- })
- }
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let res;
- res = await that.$api(`/dictData`, 'GET', {
- code: "afterSale_type"
- });
- if (res.errcode == '0') {
- let type = res.data.filter(i => i.value != '4' && i.value != '5')
- that.$set(that, `typeList`, type)
- }
- res = await that.$api(`/dictData`, 'GET', {
- code: "afterSale_reason"
- });
- if (res.errcode == '0') that.$set(that, `reasonList`, res.data)
- }
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .one {
- margin: 2vw;
- border: 1px solid #f1f1f1;
- border-radius: 5px;
- padding: 2vw;
- .one_1 {
- margin: 0 0 2vw 0;
- text {
- font-size: 16px;
- font-weight: bold;
- }
- }
- .one_2 {
- .list {
- display: flex;
- background-color: #f1f1f1;
- padding: 2vw;
- margin: 0 0 2vw 0;
- border-radius: 5px;
- .list_1 {
- width: 22vw;
- height: 22vw;
- border-radius: 5px;
- .image {
- width: 100%;
- height: 100%;
- border-radius: 5px;
- }
- }
- .list_2 {
- width: 63vw;
- padding: 0 0 0 2vw;
- .name {
- font-size: 16px;
- font-weight: bold;
- margin: 0 0 0.5vw 0;
- }
- .other_1 {
- .money {
- color: var(--fFB1Color) !important;
- }
- text {
- font-size: 13px;
- color: #858585;
- }
- text:last-child {
- color: #000000;
- }
- }
- }
- }
- .list:last-child {
- margin: 0;
- }
- .set_name {
- display: flex;
- padding: 2vw 0;
- .set {
- margin: 0 1vw 0 0;
- font-size: 12px;
- border-radius: 5px;
- padding: 0 1vw;
- color: #ffffff;
- background-color: #FF6347;
- border: 1px solid #FFA500;
- }
- }
- .set {
- display: flex;
- justify-content: space-between;
- margin: 0 0 2vw 0;
- padding: 2vw 0;
- .set_1 {
- font-size: var(--font16Size);
- color: var(--f85Color);
- }
- text {
- padding: 0 1vw 0 0;
- font-size: var(--font20Szie);
- }
- }
- }
- }
- .two {
- margin: 2vw;
- border: 1px solid #f1f1f1;
- border-radius: 5px;
- padding: 2vw;
- .two_1 {
- .picker {
- border: 1px solid #3333;
- border-radius: 5px;
- padding: 2vw;
- }
- .money {
- margin: 1vw 0 0 0;
- text {
- color: var(--fFB1Color);
- }
- text:last-child {
- color: #6A5ACD;
- }
- }
- .btn {
- text-align: center;
- }
- }
- .two_2 {
- .btn {
- text-align: center;
- button {
- background-color: var(--f35BColor);
- color: #fff;
- }
- }
- }
- }
- }
- </style>
|