|
|
@@ -90,11 +90,16 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
onTypeChange(e) {
|
|
|
+ var idx = Number(e.detail.value)
|
|
|
+ this.typeIndex = idx
|
|
|
+ this.form.productType = this.typeOptions[idx].value
|
|
|
+ },
|
|
|
+ loadProduct(id) {
|
|
|
uni.showLoading({ title: '加载中...' })
|
|
|
- productDetail({ id: Number(id) }).then(res => {
|
|
|
+ productDetail({ id: Number(id) }).then(function(res) {
|
|
|
uni.hideLoading()
|
|
|
if (res.code === 200 && res.data) {
|
|
|
- const p = res.data
|
|
|
+ var p = res.data
|
|
|
this.form.name = p.name || ''
|
|
|
this.form.intro = p.intro || ''
|
|
|
this.form.description = p.description || ''
|
|
|
@@ -103,12 +108,13 @@ export default {
|
|
|
this.form.stock = p.stock || 0
|
|
|
this.form.productType = p.productType || 'physical'
|
|
|
// sync picker index
|
|
|
- var idx = this.typeOptions.findIndex(function(t) { return t.value === this.form.productType }, this)
|
|
|
+ var self = this
|
|
|
+ var idx = this.typeOptions.findIndex(function(t) { return t.value === self.form.productType })
|
|
|
if (idx >= 0) this.typeIndex = idx
|
|
|
} else {
|
|
|
uni.showToast({ title: res.message || '加载失败', icon: 'none' })
|
|
|
}
|
|
|
- }).catch(function() {
|
|
|
+ }.bind(this)).catch(function() {
|
|
|
uni.hideLoading()
|
|
|
uni.showToast({ title: '加载失败', icon: 'none' })
|
|
|
})
|