| | |
| | | // pages/bookServices/detail/components/suggest/suggest.js |
| | | const app = getApp() |
| | | Component({ |
| | | /** |
| | | * 组件的属性列表 |
| | | */ |
| | | properties: { |
| | | |
| | | bookIcon: { |
| | | type: String, |
| | | value: '' |
| | | }, |
| | | bookName: { |
| | | type: String, |
| | | value: '' |
| | | } |
| | | }, |
| | | |
| | | data: { |
| | | inputStyle: 'border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx; padding:16rpx', |
| | | placeholderstyle: 'font-size:28rpx', |
| | | dialogKey: '', |
| | | showWithInput: false, |
| | | showTextAndTitleWithInput: false, |
| | | inputvalue: '', |
| | | textvalue: '', |
| | | ratevalue: 0, |
| | | textError: false, |
| | | }, |
| | | methods: { |
| | | showDialog(e) { |
| | |
| | | |
| | | closeDialog() { |
| | | this.setData({ |
| | | showWithInput: false |
| | | showWithInput: false, |
| | | ratevalue: 0, |
| | | inputvalue: '', |
| | | textvalue: '' |
| | | }) |
| | | }, |
| | | // 评分改变 |
| | | onChangeRate(e) { |
| | | const { value } = e.detail; |
| | | console.log(e.detail); |
| | | this.setData({ |
| | | ratevalue: value |
| | | ratevalue: e.detail.value |
| | | }); |
| | | }, |
| | | // 输入框改变 |
| | | inputChange(e) { |
| | | this.setData({ |
| | | inputvalue: e.detail.value |
| | | }) |
| | | }, |
| | | // 文本框改变 |
| | | textareaChange(e) { |
| | | this.setData({ |
| | | textvalue: e.detail.value |
| | | }) |
| | | }, |
| | | feedBack() { |
| | | const token = wx.getStorageSync('jsek-token') |
| | | if (!token) { |
| | | return wx.getUserProfile({ |
| | | desc: '用户登录', |
| | | success: (res) => { |
| | | console.log(res); |
| | | } |
| | | }) |
| | | } |
| | | this.closeDialog() |
| | | let content = { |
| | | source: this.data.ratevalue, |
| | | phone: this.data.inputvalue, |
| | | content: this.data.textvalue, |
| | | icon: this.properties.bookIcon |
| | | } |
| | | let query = { |
| | | topicIdOrRefCode: 'bookOpinion', |
| | | name: this.properties.bookName, |
| | | content: JSON.stringify(content), |
| | | type: 'ProductComment', |
| | | cmsTypeRefCode: '', |
| | | newDataListRequest: [] |
| | | } |
| | | |
| | | app.MG.ugc.newTopicMessage(query).then((res) => { |
| | | wx.showToast({ |
| | | title: '提交成功', |
| | | icon: 'success', |
| | | duration: 2000 |
| | | }) |
| | | }) |
| | | }, |
| | | // 确定 |
| | | confirmSuggest() { |
| | | const isPhoneNumber = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(this.data.inputvalue); |
| | | if (!this.data.ratevalue) { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: '请选择评分', |
| | | }) |
| | | } else if (!this.data.inputvalue) { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: '请填写联系方式', |
| | | }) |
| | | } else if (!isPhoneNumber) { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: '请输入正确联系方式', |
| | | }) |
| | | } else if (!this.data.textvalue) { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: '请输入反馈反馈内容', |
| | | }) |
| | | } |
| | | this.feedBack() |
| | | } |
| | | }, |
| | | }) |