绿满眶商城微信小程序-uniapp
peng
73 分钟以前 426b946268fcd30280512ad46993735f42d5f666
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<template>
  <div class="wrapper">
    <div v-if="!askGoods.goods_id" class="noMore">
      暂无信息
    </div>
    <div class="askBox" v-else>
      <u-row :gutter="24">
        <u-col span="2" @click="goodsDetail()">
          <image class="img" :src="queryGoodsDetail.thumbnail"></image>
        </u-col>
        <u-col span="8" @click="goodsDetail()">
          <h5 style="padding-left:10rpx;">{{queryGoodsDetail.goodsName}}</h5>
        </u-col>
 
      </u-row>
      <u-row>
        <u-col span="12">
          <u-input v-model="params.askValue" height="200" type="textarea" :border="border" />
        </u-col>
        <u-radio-group v-model="params.anonymous" @change="radioGroupChange">
          <u-radio @change="radioChange">
            匿名提交
          </u-radio>
        </u-radio-group>
        <u-col span="12">
          <u-row :gutter="12">
            <u-col :offset="1" span="4">
              <u-button class="btns" @click="askValue=''">清空</u-button>
            </u-col>
            <u-col :offset="2" span="4">
              <u-button class="btns" @click="getAskMessage()" type="success">提交</u-button>
            </u-col>
          </u-row>
        </u-col>
      </u-row>
    </div>
  </div>
</template>
<script>
import '@/components/uview-components/uview-ui'
import * as API_GOODS from "../../api/goods";
import * as API_MEM from "../../api/members";
export default {
  data() {
    return {
      askGoods: "",
      queryGoodsDetail: "",
      border: true,
      params: {
        askValue: "",
        anonymous: "YES",
      },
    };
  },
  onLoad(options) {
    this.askGoods = options;
    this.getGoodsData();
  },
  methods: {
    getGoodsData() {
      if (this.askGoods.goods_id) {
        API_GOODS.getGoods(this.askGoods.goods_id).then((result) => {
          this.queryGoodsDetail = result.data;
        });
      }
    },
    getAskMessage() {
      uni.showLoading();
      if (this.params.askValue == "") {
        uni.showToast({
          title: "请填写内容!",
          icon: "none",
        });
         if (this.$store.state.isShowToast){ uni.hideLoading() };
        return false;
      }
      API_MEM.consultating(
        this.askGoods.goods_id,
        this.params.askValue,
        this.params.anonymous
      )
        .then((res) => {
          if (res.statusCode == 200) {
            uni.showToast({
              title: "提交成功!",
              icon: "none",
            });
            this.askValue = "";
          }
           if (this.$store.state.isShowToast){ uni.hideLoading() };
        })
        .catch((err) => {
        
           if (this.$store.state.isShowToast){ uni.hideLoading() };
        });
    },
    radioGroupChange(e) {
     
    },
    radioChange(e) {
      if (this.anonymous == "YES") {
        this.anonymous = "NO";
      } else {
        this.anonymous = "YES";
      }
    },
  },
};
</script>
<style scoped lang="scss">
.img {
  max-width: 100%;
  height: 100rpx;
}
 
.noMore {
  text-align: center;
  margin: 40rpx 0;
}
 
.askBox {
  padding: 32rpx;
}
 
/deep/ .u-col {
  text-align: center;
  padding: 16rpx 0 !important;
}
 
.wrapper {
  background: #fff;
  padding: 32rpx 0;
}
</style>