|
|
@@ -16,18 +16,33 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 选择 -->
|
|
|
+ <view class="form-section">
|
|
|
+ <view class="form-item textarea-item">
|
|
|
+ <text class="form-label">公告标题</text>
|
|
|
+ <button class="admin-button-com middle blue" style="float: right;" @click="purchaseGuideText=''">清空</button>
|
|
|
+ </view>
|
|
|
+ <view class="textarea-wrapper">
|
|
|
+ <textarea
|
|
|
+ v-model="purchaseGuideText"
|
|
|
+ class="textarea-input"
|
|
|
+ placeholder="请输入标题,不超过70个字,留空会显示一张图片"
|
|
|
+ :placeholder-style="{ color: '#999999' }"
|
|
|
+ :maxlength="500"
|
|
|
+ />
|
|
|
+ <view class="char-count">{{ purchaseGuideText.length }}/70</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
<view class="form-section">
|
|
|
<view class="form-item" @click="showPicker">
|
|
|
- <text class="form-label">购买须知</text>
|
|
|
+ <text class="form-label">公告详情</text>
|
|
|
<view class="form-control">
|
|
|
- <text class="select-text">{{ selectedValue || '请选择' }}</text>
|
|
|
+ <text class="select-text">{{ selectedValue || '请选图文' }}</text>
|
|
|
<text class="arrow">></text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 按钮部分 -->
|
|
|
<view class="button-section">
|
|
|
<button class="btn btn-cancel" @click="onCancel">返回</button>
|
|
|
<button class="btn btn-submit" @click="onSubmit">提交</button>
|
|
|
@@ -46,7 +61,8 @@ export default {
|
|
|
selectedValue: '', // 选中的值
|
|
|
saveSelectedValue: '', // 保存选中的值
|
|
|
selectedId: 0, // 选中的id
|
|
|
- formData: {}
|
|
|
+ formData: {},
|
|
|
+ purchaseGuideText: '' // 公告内容
|
|
|
}
|
|
|
},
|
|
|
onShow() {
|
|
|
@@ -59,8 +75,8 @@ export default {
|
|
|
init(){
|
|
|
getShopPurchaseGuide().then(res => {
|
|
|
this.purchaseGuideData = res.data.shopExt;
|
|
|
- this.status = this.purchaseGuideData.purchaseGuide > 0 ? true : false;
|
|
|
-
|
|
|
+ this.status = res.data.shop && res.data.shop.buyNotice == 1 ? true : false;
|
|
|
+ this.purchaseGuideText = res.data.shopExt && res.data.shopExt.purchaseGuideText ? res.data.shopExt.purchaseGuideText : ''
|
|
|
// 根据 purchaseGuide 和 title 设置选中值
|
|
|
if (this.purchaseGuideData.purchaseGuide !== "0" && this.purchaseGuideData.title) {
|
|
|
this.selectedValue = `${this.purchaseGuideData.title} (id: ${this.purchaseGuideData.purchaseGuide})`;
|
|
|
@@ -75,63 +91,37 @@ export default {
|
|
|
// 状态开关变化
|
|
|
onStatusChange(e) {
|
|
|
this.status = e.detail.value
|
|
|
- console.log('状态变化:', this.status ? '开启' : '关闭')
|
|
|
if (this.status) {
|
|
|
this.selectedValue = this.saveSelectedValue;
|
|
|
} else {
|
|
|
this.selectedValue = '...';
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
// 显示选择器
|
|
|
showPicker() {
|
|
|
- if (this.status == false) {
|
|
|
- this.$msg('状态开启后,才能选择购买须知')
|
|
|
- return
|
|
|
- }
|
|
|
- uni.navigateTo({
|
|
|
- url: `/admin/picText/picTextList?selectedId=${this.selectedId}`
|
|
|
- });
|
|
|
+ uni.navigateTo({ url: `/admin/picText/picTextList?selectedId=${this.selectedId}` })
|
|
|
},
|
|
|
-
|
|
|
// 取消按钮
|
|
|
onCancel() {
|
|
|
uni.navigateBack();
|
|
|
},
|
|
|
-
|
|
|
// 提交按钮
|
|
|
onSubmit() {
|
|
|
- if (!this.selectedValue) {
|
|
|
- this.$msg('请先选择选项')
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- const formData = {
|
|
|
- picTextId: this.selectedId,
|
|
|
- switch: this.status ? 1 : 0
|
|
|
- }
|
|
|
- //console.log('提交表单数据:', formData)
|
|
|
-
|
|
|
- // 这里可以调用API提交数据
|
|
|
- uni.showLoading({
|
|
|
- title: '提交中...'
|
|
|
- })
|
|
|
-
|
|
|
+ const formData = { picTextId: this.selectedId, switch: this.status ? 1 : 0, purchaseGuideText:this.purchaseGuideText }
|
|
|
+ uni.showLoading()
|
|
|
switchPurchaseGuide(formData).then(res => {
|
|
|
uni.hideLoading();
|
|
|
if(res.code == 1){
|
|
|
- uni.showToast({
|
|
|
- title: '提交成功',
|
|
|
- icon: 'success'
|
|
|
- })
|
|
|
+ uni.showToast({ title: '提交成功', icon: 'success' })
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.navigateBack()
|
|
|
+ }, 1500);
|
|
|
} else {
|
|
|
this.$msg(res.msg)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
updateSelectedItem(data) {
|
|
|
- console.log('更新选中项:', data)
|
|
|
// 更新选中项显示
|
|
|
if (data && data.picTextId && data.title) {
|
|
|
this.selectedValue = `${data.title} (ID: ${data.picTextId})`;
|
|
|
@@ -211,6 +201,36 @@ export default {
|
|
|
margin-left: 4rpx;
|
|
|
}
|
|
|
|
|
|
+.textarea-item {
|
|
|
+ min-height: auto;
|
|
|
+ padding: 30rpx 0 20rpx 0;
|
|
|
+}
|
|
|
+
|
|
|
+.textarea-wrapper {
|
|
|
+ position: relative;
|
|
|
+ padding: 0 0 30rpx 0;
|
|
|
+}
|
|
|
+
|
|
|
+.textarea-input {
|
|
|
+ width: 100%;
|
|
|
+ height: 200rpx;
|
|
|
+ padding: 20rpx;
|
|
|
+ border: 1rpx solid #e0e0e0;
|
|
|
+ border-radius: 8rpx;
|
|
|
+ font-size: 28rpx;
|
|
|
+ color: #333333;
|
|
|
+ box-sizing: border-box;
|
|
|
+ line-height: 1.5;
|
|
|
+}
|
|
|
+
|
|
|
+.char-count {
|
|
|
+ position: absolute;
|
|
|
+ bottom: 40rpx;
|
|
|
+ right: 20rpx;
|
|
|
+ font-size: 24rpx;
|
|
|
+ color: #999999;
|
|
|
+}
|
|
|
+
|
|
|
.button-section {
|
|
|
display: flex;
|
|
|
gap: 30rpx;
|