|
|
@@ -1,109 +1,215 @@
|
|
|
<template>
|
|
|
<div class="app-content">
|
|
|
<!-- 广告信息 -->
|
|
|
- <div class="module-com input-line-wrap">
|
|
|
- <tui-list-cell class="line-cell" :hover="false">
|
|
|
- <div class="tui-title required">广告图名称</div>
|
|
|
- <input v-model="form.receiveUserName" placeholder-class="phcolor" class="tui-input" name="name" placeholder="请输入姓名" maxlength="50" type="number" />
|
|
|
- </tui-list-cell>
|
|
|
- <tui-list-cell class="line-cell" :arrow="true">
|
|
|
- <div class="tui-title required">开始时间</div>
|
|
|
- <picker mode="date" :value="form.reachTime" @change="selTimeFn" class="tui-input">
|
|
|
- <div v-if="form.reachTime">{{ form.reachTime }}</div>
|
|
|
- <div class="tui-placeholder" v-else>请选择</div>
|
|
|
- </picker>
|
|
|
- </tui-list-cell>
|
|
|
- <tui-list-cell class="line-cell" :arrow="true">
|
|
|
- <div class="tui-title required">到期时间</div>
|
|
|
- <picker mode="date" :value="form.reachTime" @change="selTimeFn" class="tui-input">
|
|
|
- <div v-if="form.reachTime">{{ form.reachTime }}</div>
|
|
|
- <div class="tui-placeholder" v-else>请选择</div>
|
|
|
- </picker>
|
|
|
- </tui-list-cell>
|
|
|
- <tui-list-cell class="line-cell between switch" padding="14rpx 30rpx" :hover="false">
|
|
|
- <div class="tui-title">马上开启</div>
|
|
|
- <div>
|
|
|
- <switch checked @change="switchChangeFn" />
|
|
|
- </div>
|
|
|
- </tui-list-cell>
|
|
|
- </div>
|
|
|
- <!-- 广告图片 -->
|
|
|
- <div class="module-com input-line-wrap">
|
|
|
- <tui-list-cell class="line-img-wrap" :hover="false">
|
|
|
- <div>
|
|
|
- <span class="ad-name required">广告图片</span>
|
|
|
- <span class="app-color-3 app-size-24">只能上传jpg/png格式</span>
|
|
|
- </div>
|
|
|
- <div class="line-img">
|
|
|
- <app-uploader @chooseImage="chooseUploader" :multiple="false" ref="appUploader" :imgList.sync="imgList" />
|
|
|
- </div>
|
|
|
- </tui-list-cell>
|
|
|
- </div>
|
|
|
- <!-- 链接方式 -->
|
|
|
- <div class="module-com input-line-wrap">
|
|
|
- <tui-list-cell class="line-cell" :hover="false">
|
|
|
- <div class="tui-title required">链接方式</div>
|
|
|
- <radio-group class="tui-input flex-center-between" @change="radioChange">
|
|
|
- <label class="list" for="customLink">
|
|
|
- <radio id="customLink" value="自定义链接" checked="checked" />
|
|
|
- <span class="checkbox-text">自定义链接</span>
|
|
|
- </label>
|
|
|
- <label class="list" for="goodsLink">
|
|
|
- <radio id="goodsLink" value="链接商品" />
|
|
|
- <span class="checkbox-text">链接商品</span>
|
|
|
- </label>
|
|
|
- </radio-group>
|
|
|
- </tui-list-cell>
|
|
|
- <block v-if="false">
|
|
|
+ <form @submit="formSubmit">
|
|
|
+ <div class="module-com input-line-wrap">
|
|
|
<tui-list-cell class="line-cell" :hover="false">
|
|
|
- <textarea class="tui-textarea" placeholder-class="phcolor" placeholder="请填写链接,留空点图片不跳转" auto-height />
|
|
|
+ <div class="tui-title required">广告图名称</div>
|
|
|
+ <input v-model="form.adName" placeholder-class="phcolor" class="tui-input" name="adName" placeholder="请输入名称" maxlength="50" type="text" />
|
|
|
</tui-list-cell>
|
|
|
- </block>
|
|
|
- <block v-else>
|
|
|
- <tui-list-cell class="goods-blo" :hover="false">
|
|
|
- <div class="goods-list-wrap">
|
|
|
- <div class="goods-list" v-for="(item, index) in 2" :key="index">
|
|
|
- <div class="list-img">
|
|
|
- <img src="../../static/images/interest/invite.png" alt mode="center" />
|
|
|
- </div>
|
|
|
- <div class="list-right">
|
|
|
- <div>花之物语 红色系</div>
|
|
|
- <div class="app-price">¥389.50</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
+ <tui-list-cell class="line-cell" :arrow="true">
|
|
|
+ <div class="tui-title required">开始时间</div>
|
|
|
+ <picker mode="date" :value="form.startTime" @change="startTimeFn" class="tui-input">
|
|
|
+ <input v-model="form.startTime" name="startTime" type="text" hidden />
|
|
|
+ <div v-if="form.startTime">{{ form.startTime }}</div>
|
|
|
+ <div class="tui-placeholder" v-else>请选择</div>
|
|
|
+ </picker>
|
|
|
+ </tui-list-cell>
|
|
|
+ <tui-list-cell class="line-cell" :arrow="true">
|
|
|
+ <div class="tui-title required">到期时间</div>
|
|
|
+ <picker mode="date" :value="form.endTime" @change="endTimeFn" class="tui-input">
|
|
|
+ <input v-model="form.endTime" name="endTime" type="text" hidden />
|
|
|
+ <div v-if="form.endTime">{{ form.endTime }}</div>
|
|
|
+ <div class="tui-placeholder" v-else>请选择</div>
|
|
|
+ </picker>
|
|
|
+ </tui-list-cell>
|
|
|
+ <tui-list-cell class="line-cell between switch" padding="14rpx 30rpx" :hover="false">
|
|
|
+ <div class="tui-title">马上开启</div>
|
|
|
+ <div>
|
|
|
+ <switch :checked="form.status ? true : false" @change="switchChangeFn" />
|
|
|
</div>
|
|
|
- <div class="admin-button-com blue" @click="$util.pageTo('/pages/ad/sel-goods')">选择商品</div>
|
|
|
</tui-list-cell>
|
|
|
- </block>
|
|
|
- </div>
|
|
|
- <!-- 确认 -->
|
|
|
- <div class="confirm-btn">
|
|
|
- <div class="admin-button-com big blue">确认</div>
|
|
|
- </div>
|
|
|
+ </div>
|
|
|
+ <!-- 广告图片 -->
|
|
|
+ <div class="module-com input-line-wrap">
|
|
|
+ <tui-list-cell class="line-img-wrap" :hover="false">
|
|
|
+ <div>
|
|
|
+ <span class="ad-name required">广告图片</span>
|
|
|
+ <span class="app-color-3 app-size-24">只能上传jpg/png格式</span>
|
|
|
+ </div>
|
|
|
+ <div class="line-img">
|
|
|
+ <input v-model="form.endTime" name="endTime" type="text" hidden />
|
|
|
+ <app-uploader @chooseImage="chooseUploader" :multiple="false" ref="appUploader" :imgList.sync="imgList" />
|
|
|
+ </div>
|
|
|
+ </tui-list-cell>
|
|
|
+ </div>
|
|
|
+ <!-- 链接方式 -->
|
|
|
+ <div class="module-com input-line-wrap">
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <div class="tui-title required">链接方式</div>
|
|
|
+ <radio-group class="tui-input flex-center-between" @change="radioChange">
|
|
|
+ <label class="list" for="customLink">
|
|
|
+ <radio id="customLink" value="0" :checked="form.style == 0" />
|
|
|
+ <span class="checkbox-text">自定义链接</span>
|
|
|
+ </label>
|
|
|
+ <label class="list" for="goodsLink">
|
|
|
+ <radio id="goodsLink" value="1" :checked="form.style == 1" />
|
|
|
+ <span class="checkbox-text">链接商品</span>
|
|
|
+ </label>
|
|
|
+ </radio-group>
|
|
|
+ </tui-list-cell>
|
|
|
+ <block v-if="form.style == 0">
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <textarea v-model="form.url" class="tui-textarea" placeholder-class="phcolor" placeholder="请填写链接,留空点图片不跳转" auto-height />
|
|
|
+ </tui-list-cell>
|
|
|
+ </block>
|
|
|
+ <block v-else>
|
|
|
+ <tui-list-cell class="goods-blo" :hover="false">
|
|
|
+ <div class="goods-list-wrap" v-if="!$util.isEmpty(goodsData)">
|
|
|
+ <div class="goods-list">
|
|
|
+ <div class="list-img">
|
|
|
+ <img :src="goodsData.imgSmallList[0]" alt="商品图片" mode="center" />
|
|
|
+ </div>
|
|
|
+ <div class="list-right">
|
|
|
+ <div>{{ goodsData.goodsName }}</div>
|
|
|
+ <div class="app-price">¥{{ goodsData.price }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="admin-button-com blue" @click="selGoodsFn">选择商品</div>
|
|
|
+ </tui-list-cell>
|
|
|
+ </block>
|
|
|
+ </div>
|
|
|
+ <!-- 确认 -->
|
|
|
+ <div class="confirm-btn">
|
|
|
+ <button class="admin-button-com big blue" formType="submit">确认</button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import TuiListCell from '@/components/plugin/list-cell'
|
|
|
import AppUploader from '@/components/app-uploader'
|
|
|
+import AppDatePicker from '@/components/app-date-picker'
|
|
|
+const form = require('@/utils/formValidation.js')
|
|
|
+// api
|
|
|
+import { getDet, add, update } from '@/api/ad'
|
|
|
+import { getDetailB as getGoodsDet } from '@/api/goods'
|
|
|
export default {
|
|
|
name: 'ad-add',
|
|
|
components: {
|
|
|
TuiListCell,
|
|
|
- AppUploader
|
|
|
+ AppUploader,
|
|
|
+ AppDatePicker
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- form: {},
|
|
|
- imgList: []
|
|
|
+ form: {
|
|
|
+ adName: '',
|
|
|
+ adImg: '',
|
|
|
+ status: 0,
|
|
|
+ inTurn: '',
|
|
|
+ type: 0,
|
|
|
+ style: 0,
|
|
|
+ url: '',
|
|
|
+ goodsId: '',
|
|
|
+ startTime: null,
|
|
|
+ endTime: null
|
|
|
+ },
|
|
|
+ imgList: [],
|
|
|
+ goodsData: {}
|
|
|
}
|
|
|
},
|
|
|
+ onLoad(option) {
|
|
|
+ this.setPageTitle()
|
|
|
+ this.init()
|
|
|
+ },
|
|
|
methods: {
|
|
|
- selTimeFn(e) {
|
|
|
- this.form.reachTime = e.detail.value
|
|
|
+ init() {
|
|
|
+ this.type = this.option.type
|
|
|
+
|
|
|
+ let data = uni.getStorageSync('addAdData')
|
|
|
+ if (data) {
|
|
|
+ uni.removeStorageSync('addAdData')
|
|
|
+ this.form = data.form
|
|
|
+ this.imgList = data.imgList
|
|
|
+ this.goodsData = data.goodsData
|
|
|
+ }
|
|
|
+ let goodsData = uni.getStorageSync('adSelGoods')
|
|
|
+ if (goodsData) {
|
|
|
+ uni.removeStorageSync('adSelGoods')
|
|
|
+ this.goodsData = goodsData
|
|
|
+ this.goodsId = goodsData.id
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.option.id && !data) {
|
|
|
+ this._getDet()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setPageTitle() {
|
|
|
+ if (this.option.id) {
|
|
|
+ uni.setNavigationBarTitle({
|
|
|
+ title: this.option.type == 0 ? '修改门店轮播图' : '修改商城首页轮播图'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.setNavigationBarTitle({
|
|
|
+ title: this.option.type == 0 ? '添加门店轮播图' : '添加商城首页轮播图'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // api
|
|
|
+ _getDet() {
|
|
|
+ getDet({ id: this.option.id }).then(res => {
|
|
|
+ if (this.$util.isEmpty(res.data)) return
|
|
|
+ Object.keys(this.form).forEach((i, index) => {
|
|
|
+ this.form[i] = res.data[i]
|
|
|
+ })
|
|
|
+ this.form.startTime = this.$util.$formatDate(this.form.startTime, 'YYYY-MM-DD')
|
|
|
+ this.form.endTime = this.$util.$formatDate(this.form.endTime, 'YYYY-MM-DD')
|
|
|
+
|
|
|
+ if (this.form.style) {
|
|
|
+ this._getGoodsDet()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 获取商品详情
|
|
|
+ _getGoodsDet() {
|
|
|
+ getGoodsDet({ id: this.form.goodsId }).then(res => {
|
|
|
+ if (this.$util.isEmpty(res.data)) return
|
|
|
+ this.goodsData = res.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 操作
|
|
|
+ // 选择商品
|
|
|
+ selGoodsFn() {
|
|
|
+ let data = {
|
|
|
+ form: this.form,
|
|
|
+ imgList: this.imgList,
|
|
|
+ goodsData: this.goodsData
|
|
|
+ }
|
|
|
+ uni.setStorageSync('addAdData', data)
|
|
|
+ // this.form
|
|
|
+ this.$util.pageTo({
|
|
|
+ url: '/pages/ad/sel-goods',
|
|
|
+ query: {
|
|
|
+ ...this.option
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ startTimeFn(e) {
|
|
|
+ console.log(e)
|
|
|
+ // this.form.startTime = e
|
|
|
+ },
|
|
|
+ endTimeFn(e) {
|
|
|
+ this.form.endTime = e.detail.value
|
|
|
+ },
|
|
|
+ switchChangeFn(e) {
|
|
|
+ this.switch = e.target.value ? 1 : 0
|
|
|
+ },
|
|
|
+ radioChange(e) {
|
|
|
+ this.form.style = e.detail.value
|
|
|
},
|
|
|
- switchChangeFn() {},
|
|
|
- radioChange() {},
|
|
|
chooseUploader() {
|
|
|
console.log('afda')
|
|
|
// modifySiteCover({
|
|
|
@@ -117,6 +223,51 @@ export default {
|
|
|
// icon: 'none'
|
|
|
// })
|
|
|
// })
|
|
|
+ },
|
|
|
+ confirmFn() {
|
|
|
+ let hostFn = this.option.id ? update : add
|
|
|
+ if (this.option.id) {
|
|
|
+ this.form.id = this.option.id
|
|
|
+ }
|
|
|
+ if (this.form.style == 0) {
|
|
|
+ this.form.goodsId = ''
|
|
|
+ } else {
|
|
|
+ this.form.url = ''
|
|
|
+ }
|
|
|
+ hostFn(this.form).then(res => {
|
|
|
+ let promptText = this.option.id ? '修改成功!' : '添加成功!'
|
|
|
+ this.$msg(promptText)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 表单验证
|
|
|
+ formSubmit(e) {
|
|
|
+ // 表单规则
|
|
|
+ let rules = [
|
|
|
+ {
|
|
|
+ name: 'adName',
|
|
|
+ rule: ['required'],
|
|
|
+ msg: ['请输入姓名']
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'startTime',
|
|
|
+ rule: ['required'],
|
|
|
+ msg: ['请选择开始时间']
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'endTime',
|
|
|
+ rule: ['required'],
|
|
|
+ msg: ['请选择结束时间']
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ // 进行表单检查
|
|
|
+ let formData = e.detail.value
|
|
|
+ let checkRes = form.validation(formData, rules)
|
|
|
+ // 验证通过!
|
|
|
+ if (!checkRes) {
|
|
|
+ this.confirmFn()
|
|
|
+ } else {
|
|
|
+ this.$msg(checkRes)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -170,7 +321,7 @@ export default {
|
|
|
width: calc(100% - 60px);
|
|
|
margin: 60px 30px 20px;
|
|
|
.admin-button-com {
|
|
|
- width: calc(100% - 40px);
|
|
|
+ width: 100%;
|
|
|
}
|
|
|
}
|
|
|
</style>
|