| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- <template>
- <view>
- <view class="from flex justify-center">
- <view class="from-box flex justify-center">
- <view class="from-box-c">
- <u-form :model="form" label-position="top" ref="uForm">
- <u-form-item label="优惠券名称">
- <u-input v-model="form.couponName" placeholder="请输入优惠券名称" />
- </u-form-item>
- <u-form-item label="有效期天数">
- <u-input v-model="form.endDate" type="number" placeholder="请选择有效期天数" />
- </u-form-item>
- <u-form-item label="可使用订单最低金额">
- <u-input v-model="form.minMoney" type="number" placeholder="请输入可使用订单最低金额" />
- </u-form-item>
- <!-- <u-form-item label="所需积分数">
- <u-input v-model="form.needIntegral" type="number" placeholder="请输入所需积分数" />
- </u-form-item> -->
- <u-form-item label="优惠券金额">
- <u-input v-model="form.money" type="number" placeholder="请输入优惠券金额" />
- </u-form-item>
- <u-form-item label="优惠券图片">
- <u-upload ref="uUpload" :file-list="fileList" :multiple="false" max-count="1" :action="action" @on-remove="onRemove" @on-change="onChange"></u-upload>
- </u-form-item>
- </u-form>
- </view>
- </view>
- </view>
- <!-- 保存 -->
- <view class="button flex justify-center align-center">
- <view class="button-box flex justify-center align-center" @click="sumbit()">
- 保存
- </view>
- </view>
- </view>
- </template>
- <script>
- import configdata from '@/common/config.js';
- export default {
- data() {
- return {
- action: '',
- // action: config.APIHOST+'/alioss/upload',
- fileList: [],
- form: {
- couponId:'',
- couponName: '',
- endDate: '',
- minMoney: '',
- // needIntegral: '',
- money: '',
- shopId: uni.getStorageSync('shopId'),
- couponPicture: '',
- },
- };
- },
- onShow() {
- let that = this
- that.action=that.config("APIHOST1") + '/alioss/upload'
- },
- onLoad(option) {
- let info = JSON.parse(option.info)
- this.fileList = [
- {url:info.couponPicture}
- ]
- this.form = {
- couponId:info.couponId,
- couponName: info.couponName,
- endDate: info.endDate,
- minMoney: info.minMoney,
- // needIntegral: info.needIntegral,
- money: info.money,
- shopId: uni.getStorageSync('shopId'),
- couponPicture: info.couponPicture,
- },
- console.log(this.form,this.form.couponName)
- },
- methods: {
- onRemove(e){
- this.form.couponPicture = ''
- },
- onChange(e){
-
- if(e.data){
- let obj = JSON.parse(e.data)
- if(obj.code!=0){
- uni.showToast({
- title:'上传失败,请重新上传!',
- icon:'none'
- })
-
- this.$refs.uUpload.clear()
- }else{
- this.form.couponPicture = obj.data
- }
-
- }else{
- uni.showToast({
- title:'上传失败,请重新上传!',
- icon:'none'
- })
- this.$refs.uUpload.clear()
- }
- },
- //提交
- sumbit(){
- if(!this.form.couponName){
- uni.showToast({
- title:'请输入优惠券名称',
- icon:'none'
- })
- return
- }
- if(!this.form.endDate){
- uni.showToast({
- title:'请输入有效期天数',
- icon:'none'
- })
- return
- }
- if(!this.form.minMoney){
- uni.showToast({
- title:'请输入可使用订单最低金额',
- icon:'none'
- })
- return
- }
- // if(!this.form.needIntegral){
- // uni.showToast({
- // title:'请输入所需积分数',
- // icon:'none'
- // })
- // return
- // }
- if(!this.form.money){
- uni.showToast({
- title:'请输入优惠券金额',
- icon:'none'
- })
- return
- }
- if(!this.form.couponPicture){
- uni.showToast({
- title:'请上传优惠券图片',
- icon:'none'
- })
- return
- }
- uni.showLoading({
- title:'提交中...'
- })
- this.$Request.postJson("/admin/coupon/updateCoupon", this.form).then(res => {
- if (res.code == 0) {
- uni.showToast({
- title:'修改成功'
- })
- setTimeout(()=>{
- uni.navigateBack()
- },1000)
- }else{
- uni.showModal({
- title: '提示',
- content: res.msg,
- success: function (res) {
- if (res.confirm) {
- } else if (res.cancel) {
- }
- }
- });
- }
- uni.hideLoading()
- });
-
- },
- config: function(name) {
- var info = null;
- if (name) {
- var name2 = name.split("."); //字符分割
- if (name2.length > 1) {
- info = configdata[name2[0]][name2[1]] || null;
- } else {
- info = configdata[name] || null;
- }
- if (info == null) {
- let web_config = cache.get("web_config");
- if (web_config) {
- if (name2.length > 1) {
- info = web_config[name2[0]][name2[1]] || null;
- } else {
- info = web_config[name] || null;
- }
- }
- }
- }
- return info;
- },
- },
- }
- </script>
- <style lang="scss">
- .from {
- width: 100%;
- height: auto;
- margin-top: 30rpx;
- .from-box {
- width: 686rpx;
- height: 100%;
- border-radius: 16rpx;
- background-color: #ffffff;
- .from-box-c {
- width: 646rpx;
- }
- }
- }
- .button {
- width: 100%;
- height: 120rpx;
- background-color: rgb(241, 241, 241);
- position: fixed;
- bottom: 0;
- z-index: 999;
- .button-box {
- width: 686rpx;
- height: 80rpx;
- border-radius: 40rpx;
- background-color: #FCD202;
- }
- }
- </style>
|