123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490 |
- <template>
- <mobile-frame>
- <view class="info">
- <view class="one">
- <view class="one_1">
- <text>评论商品</text>
- </view>
- <view class="one_2" v-if="status=='0'">
- <view v-for="(item,index) in goodsList" :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">
- <uni-forms ref="form" :modelValue="form" :rules="rules" label-width="auto">
- <uni-forms-item label="评论商品" name="goods" v-if="status=='0'&&goodssList.length>0&&!form.set">
- <picker class="picker" mode="selector" :range="goodssList" @change="goodsChange"
- range-key="goods_name">
- <view>{{form.goods_name||'请选择评论商品'}}</view>
- </picker>
- </uni-forms-item>
- <uni-forms-item label="评论套装" name="set" v-if="status=='0'&&!form.goods_name&&setList.length>0">
- <picker class="picker" mode="selector" :range="setList" @change="setChange" range-key="name">
- <view>{{form.set_name||'请选择评论套装'}}</view>
- </picker>
- </uni-forms-item>
- <uni-forms-item label="评论套装商品" name="goods" v-if="status=='0'&&form.set">
- <picker class="picker" mode="selector" :range="setgoodsList" @change="setgoodsChange"
- range-key="goods_name">
- <view>{{form.goods_name||'请选择评论套装商品'}}</view>
- </picker>
- </uni-forms-item>
- <uni-forms-item label="评论内容" name="content">
- <uni-easyinput maxlength=-1 type="textarea" v-model="form.content" placeholder="请输入评论内容" />
- </uni-forms-item>
- <uni-forms-item label="上传评论图片" name="file" v-if="readonly==false">
- <upload :list="file" name="file" :count="6" @uplSuc="uplSuc" @uplDel="uplDel"></upload>
- </uni-forms-item>
- <uni-forms-item label="商品评分" name="goods_score">
- <uni-rate :readonly="readonly" size="18" v-model="form.goods_score" />
- </uni-forms-item>
- <uni-forms-item label="发货评分" name="transport_score">
- <uni-rate :readonly="readonly" size="18" v-model="form.transport_score" />
- </uni-forms-item>
- <uni-forms-item label="店铺评分" name="shop_score">
- <uni-rate :readonly="readonly" size="18" v-model="form.shop_score" />
- </uni-forms-item>
- </uni-forms>
- <view class="btn">
- <button type="primary" @click="onSubmit('form')" size="small">提交</button>
- </view>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- import moment from 'moment';
- import upload from '../components/upload/index.vue';
- export default {
- components: {
- upload
- },
- data() {
- return {
- id: '',
- status: '',
- // 追加
- rate_id: '',
- user: {},
- form: {},
- info: {},
- file: [],
- // 商品
- goodsList: [],
- rules: {
- content: {
- rules: [{
- required: true,
- errorMessage: '请输入评论内容',
- }]
- },
- grade: {
- rules: [{
- required: true,
- errorMessage: '请输入评论等级',
- }]
- },
- goods: {
- rules: [{
- required: true,
- errorMessage: '请选择评论商品',
- }]
- },
- },
- readonly: false,
- // 正常商品
- goodssList: [],
- // 套装
- setList: [],
- // 套装商品
- setgoodsList: [],
- };
- },
- onLoad: function(e) {
- const that = this;
- that.$set(that, `id`, e.id || '');
- that.$set(that, `status`, e.status || '');
- // 监听用户是否登录
- 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(err) {
- uni.navigateTo({
- url: `/pages/login/index`
- })
- }
- });
- },
- // 查询列表
- async search() {
- const that = this;
- let user = that.user;
- let res;
- if (that.id) {
- if (that.status == '0') {
- res = await that.$api(`/orderDetail/${that.id}`);
- if (res.errcode == '0') {
- that.$set(that, `info`, res.data.order);
- for (let val of res.data.goods) val.goods_name = val.goods.name
- that.$set(that, `goodsList`, res.data.goods);
- let goodssList = res.data.goods.filter(i => i.is_set != '0')
- that.$set(that, `goodssList`, goodssList)
- let setList = res.data.goods.filter(i => i.is_set == '0')
- that.$set(that, `setList`, setList)
- uni.hideLoading();
- }
- } else {
- res = await that.$api(`/groupOrder/${that.id}`, {}, 'group');
- if (res.errcode == '0') {
- if (res.data.rate) {
- that.$set(that, `rate_id`, res.data.rate);
- let arr = await that.$api(`/goodsRate/${res.data.rate}`);
- if (arrarr.errcode == '0') {
- that.$set(that, `form`, arr.data);
- that.$set(that.form, `goods_name`, res.data.goods.name);
- that.$set(that, `readonly`, true)
- }
- } else {
- that.$set(that.form, `goods`, res.data.goods._id);
- that.$set(that.form, `goods_name`, res.data.goods.name);
- that.$set(that.form, `goodsSpec`, res.goodsSpec.data._id);
- }
- uni.hideLoading();
- }
- }
- }
- },
- async goodsChange(e) {
- const that = this;
- let data = that.goodssList[e.detail.value];
- if (data) that.$set(that, `goodsList`, [data])
- if (data.rate) {
- that.$set(that, `rate_id`, data.rate);
- let res = await that.$api(`/goodsRate/${data.rate}`);
- if (res.errcode == '0') {
- that.$set(that, `form`, res.data);
- that.$set(that.form, `goods_name`, data.goods_name);
- that.$set(that, `readonly`, true)
- }
- } else {
- that.$set(that.form, `goods`, data.goods._id);
- that.$set(that.form, `goods_name`, data.goods_name);
- that.$set(that.form, `goodsSpec`, data._id);
- }
- },
- // 套装
- setChange(e) {
- const that = this;
- let data = that.setList[e.detail.value];
- if (data) {
- that.$set(that, `setgoodsList`, data.goods)
- that.$set(that, `goodsList`, [data])
- }
- that.$set(that.form, `set`, data._id);
- that.$set(that.form, `set_name`, data.name);
- },
- // 套装商品
- async setgoodsChange(e) {
- const that = this;
- let data = that.setgoodsList[e.detail.value];
- if (data.rate) {
- that.$set(that, `rate_id`, data.rate);
- let res = await that.$api(`/goodsRate/${data.rate}`);
- if (res.errcode == '0') {
- that.$set(that, `form`, res.data);
- that.$set(that.form, `goods_name`, data.goods_name);
- that.$set(that, `readonly`, true)
- }
- } else {
- that.$set(that.form, `goods`, data.goods._id);
- that.$set(that.form, `goods_name`, data.goods_name);
- that.$set(that.form, `goodsSpec`, data.spec._id);
- }
- },
- // 图片上传
- uplSuc(e) {
- const that = this;
- that.$set(that, `${e.name}`, [...that[e.name], e.data]);
- },
- // 图片删除
- uplDel(e) {
- const that = this;
- let data = that[e.name];
- let arr = data.filter((i, index) => index != e.data.index);
- that.$set(that, `${e.name}`, arr)
- },
- // 提交保存
- async onSubmit(ref) {
- const that = this;
- that.$refs[ref].validate().then(async params => {
- if (that.rate_id) {
- let reply = that.form;
- let obj = {
- file: that.file,
- content: params.content,
- time: moment().format('YYYY-MM-DD HH:mm:ss')
- }
- reply.reply.push(obj)
- const arr = await that.$api(`/goodsRate/${that.rate_id}`, 'POST', reply)
- if (arr.errcode == '0') {
- uni.showToast({
- title: `追加成功`,
- icon: 'success',
- });
- uni.navigateBack({
- detail: 1
- })
- } else {
- uni.showToast({
- title: arr.errmsg,
- icon: 'none',
- })
- }
- } else {
- let reply = [{
- file: that.file,
- content: params.content,
- time: moment().format('YYYY-MM-DD HH:mm:ss')
- }];
- if (that.form.set) params.set_id = that.form.set
- params.orderDetail = that.id
- params.reply = reply;
- params.customer = that.user?._id;
- params.shop = that.info?.goods[0]?.shop;
- params.goodsSpec = that.form.goodsSpec;
- const arr = await that.$api(`/goodsRate`, 'POST', params);
- if (arr.errcode == '0') {
- uni.showToast({
- title: `评论成功`,
- icon: 'success',
- });
- uni.navigateBack({
- detail: 1
- })
- } else {
- uni.showToast({
- title: arr.errmsg,
- icon: 'none',
- })
- }
- }
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .info {
- 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 {
- padding: 2vw;
- .picker {
- width: 100%;
- border: 1px solid #3333;
- border-radius: 5px;
- padding: 2vw;
- }
- .uni-input {
- border: #f1f1ff 1px solid;
- padding: 2vw 2vw;
- border-radius: 1vw;
- }
- .btn {
- text-align: center;
- button {
- margin: 0 2vw 2vw 2vw;
- background-color: var(--fFB1Color);
- color: var(--fffColor);
- }
- .name {
- color: var(--f85Color);
- font-size: var(--font14Size);
- }
- }
- }
- }
- .uni-forms-item {
- margin-bottom: 6vw !important;
- display: flex;
- flex-direction: row;
- }
- .uni-forms-item__content {
- display: flex;
- align-items: center;
- }
- </style>
|