123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629 |
- <template>
- <view class="pages">
- <form @submit="formSubmit" @reset="formReset">
- <view class="form-item-type nomal-top">
- <view class="form-item">
- <view class="form-item-til">类目</view>
- <view class="form-item-con">
- <input type="text" disabled placeholder="商品类目" v-model="params.type" value="" />
- </view>
- </view>
-
-
- </view>
- <view class="form-item-type">
- <view class="form-item">
- <view class="form-item-til">标题</view>
- <view class="form-item-con">
- <input type="text" placeholder="请输入发布产品标题" v-model="params.title" value="" />
- </view>
- </view>
- <view class="form-item">
- <view class="form-item-til">品牌</view>
- <view class="form-item-con">
- <input type="text" placeholder="请输入品牌" v-model="params.brand" value="" />
- </view>
- </view>
- <view class="form-item">
- <view class="form-item-til">零售价</view>
- <view class="form-item-con">
- <input type="text" placeholder="请输入零售价" v-model="params.price" value="" />
- </view>
- </view>
- <view class="form-item">
- <view class="form-item-til">供应商</view>
- <view class="form-item-con">
- <input type="text" disabled placeholder="" v-model="params.supplier" value="" />
- </view>
- </view>
- <view class="form-item arrow" @click="openplaceoforigin">
- <view class="form-item-til">生产地</view>
- <view class="form-item-con">
- <input type="text" disabled="disabled" placeholder="" v-model="params.placeoforigin" value="" />
- </view>
- </view>
- <view class="form-item arrow" @click="openspecifications">
- <view class="form-item-til">规格</view>
- <view class="form-item-con">
- <text v-for="(item,index) in params.specifications">{{item}},</text>
-
- </view>
- </view>
- <view class="form-item">
- <view class="form-item-til">保质期</view>
- <view class="form-item-con">
- <input type="text" placeholder="请输入保质期" v-model="params.shelflife" value="" />
- </view>
- </view>
- <view class="form-item">
- <view class="form-item-til">生产日期</view>
- <view class="form-item-con">
- <picker mode="date" :value="params.date" :start="startDate" :end="endDate" @change="bindDateChange">
- <view class="uni-input">{{params.date}}</view>
- </picker>
-
- </view>
- </view>
- <view class="form-item">
- <view class="form-item-til">包装</view>
- <view class="form-item-con">
- <input type="text" placeholder="请输入包装" v-model="params.packaging" value="" />
- </view>
- </view>
- <view class="form-item">
- <view class="form-item-til">标签</view>
- <view class="form-item-con">
- <input type="text" placeholder="请输入标签,用逗号隔开" v-model="params.productlabel" value="" />
- </view>
- </view>
- </view>
- <view class="form-item upfile">
- <view class="form-item-til">图片视频</view>
- <view class="form-item-con">
- <view class="form-item-chooseIMGs-wrap">
- <image v-for="(item,index) in params.media" :key="index" :src="item" class="choosedIMG" ></image>
- </view>
- <view class="chooseIMG-btn">
- <image class="chooseIMG-btn-img" @click="chooseimg" src="/static/img/icon-upload.png"></image>
- </view>
- </view>
- </view>
- </form>
- <view class="bottom-btn-wrap">
- <button class="bottom-btn" @click="publish" type="primary">发布</button>
- </view>
-
-
-
- {{item}}
-
-
- <view class="placeoforigin-page fix-content translate" :class="{ 'open': placeoforiginopen }" >
- <view class="search-wrap search-left-color">
- <view class="search">
- <view class="searchTxt">
- <uni-search-bar placeholder="搜索产地关键词" @confirm="searchplace" @input="searchplace" ></uni-search-bar>
- </view>
- </view>
- </view>
-
- <scroll-view class="simplepage-wrap" scroll-y="true">
- <view v-for="(item,index) in placeoforiginlist" :key="index" @click="placeoforiginclick(item.detailAddress)" class="simplepage-item">{{item.detailAddress}}</view>
- </scroll-view>
- </view>
-
-
- <view class="specifications-page fix-content translate" :class="{ 'open': specificationsopen }" >
- <view class="specifications-wrap wrap">
- <checkbox-group @change="checkboxChange">
- <label v-for="(item,index) in specificationslist" :key="index" class="checkbox-style" >
- <checkbox :value="item.value" :checked="item.checked" />{{item.name}}
- </label>
- </checkbox-group>
- <view class="pecifications-btn-wrap">
- <button type="default" class="big-btn big-btn-hollow" @click="resetcheckbox">重置</button>
- <button type="default" class="big-btn primary" @click="specificationsclick">确定</button>
- </view>
- </view>
- </view>
-
- </view>
- </template>
- <script>
-
- import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
-
- import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue";
-
- import uniSearchBar from '@/components/uni-search-bar/uni-search-bar.vue';
- import { bus } from '../../utils/bus.js';
- export default {
- mixins: [MescrollMixin],
- components: {
- MescrollBody,
- uniSearchBar,
-
-
- },
- data() {
- const currentDate = this.getDate({
- format: true
- })
- return {
- mescroll: null,
-
- downOption: {
-
- },
-
- upOption: {
- page: {
- size: 10
- },
- noMoreSize: 5,
- empty: {
- tip: '暂无相关数据'
- }
- },
- params: {
- token: '',
- type:'',
- myposition:'',
- title:'',
- brand:'',
- price:'',
- supplier:'默认的供应商',
- placeoforigin:'',
- specifications:[],
- shelflife:'',
- date: currentDate,
- packaging:'',
- productlabel:'',
- media:[],
- },
-
- checkStatus:false,
-
- supplieropen:false,
- supplierlist:[],
-
- placeoforiginopen:false,
- placeoforiginlist:[],
- places:[],
-
- specificationsopen:false,
- specificationslist:[
- {value: '500g/提(250g/盒*2)',name: '500g/提(250g/盒*2)',checked: false},
- {value: '10g/罐',name: '10g/罐',checked: false},
- {value: '30g/盒',name: '30g/盒',checked: false},
- {value: '150g/盒',name: '150g/盒',checked: false},
- {value: '30g/盒(1.5g*20瓶)',name: '30g/盒(1.5g*20瓶)',checked: false},
- ],
- backtyep:1,
- }
- },
- onShow() {
- uni.hideTabBar();
- let serf = this;
-
-
-
-
-
-
- },
- onHide() {
- uni.showTabBar()
- },
- onLoad(option) {
- let self = this;
- if(Object.keys(bus.data).length>0){
- console.log('bus.data',bus.data)
- this.params.type = bus.data.name;
-
- };
-
-
-
- uni.getStorage({
- key:'token',
- success: function (res) {
- self.params.token = res.data;
-
- }
- });
- uni.getStorage({
- key:'tokenhead',
- success: function (res) {
- self.params.tokenhead = res.data;
-
- }
- });
-
-
- let thetoken = this.params.tokenhead+this.params.token;
- this.$api.http.get(this.config.apiBaseurl+'/company/cp/detail',{header: {Authorization:thetoken},params:{compId:72}}).then(res =>{
- console.log('res',JSON.parse(JSON.stringify(res)));
- this.placeoforiginlist = res.data.data.origines;
- this.places = res.data.data.origines;
- this.params.supplier= res.data.data.compName;
- }).catch( err => {
- console.log(err)
- });
-
- },
- computed: {
- startDate() {
- return this.getDate('start');
- },
- endDate() {
- return this.getDate('end');
- }
- },
- methods: {
- getDate(type) {
- const date = new Date();
- let year = date.getFullYear();
- let month = date.getMonth() + 1;
- let day = date.getDate();
-
- if (type === 'start') {
- year = year - 60;
- } else if (type === 'end') {
- year = year + 2;
- }
- month = month > 9 ? month : '0' + month;;
- day = day > 9 ? day : '0' + day;
- return `${year}-${month}-${day}`;
- },
- bindDateChange: function(e) {
- this.params.date = e.target.value
-
- },
-
- mescrollInit(mescroll) {
- this.mescroll = mescroll;
- },
- downCallback(){
- this.mescroll.resetUpScroll();
- },
-
- upCallback(page) {
- let pageNum = page.num;
- let pageSize = page.size;
- this.params = Object.assign(this.params,{page:pageNum,rows:pageSize});
- this.$api.http.post(this.config.apiBaseurl+'hotel/reserve/data',this.params,{
- header: {
- Accept:'application/json',
- Authorization: 'Bearer '+ this.params.token,
- }
- }).then(data => {
- if(data.data.code=='1001'){
-
-
-
- };
- console.log(data);
-
- let curPageData = data.data.rows;
- console.log('curPageData',curPageData);
-
- let curPageLen = curPageData.length;
-
-
-
- let totalSize = data.data.total;
-
-
-
-
- if(page.num == 1) this.dataList = [];
- this.dataList = this.dataList.concat(curPageData);
-
-
- this.mescroll.endBySize(curPageLen, totalSize);
-
-
-
-
-
- }).catch(err => {
- this.mescroll.endErr()
- console.log(err)
-
- });
- },
-
- chooseimg() {
- let _self = this;
- uni.chooseImage({
- count: 3,
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success: function(res) {
- const tempFilePaths = res.tempFilePaths;
- _self.image = tempFilePaths[0];
- console.log("tempFilePaths[0]", tempFilePaths[0])
- _self.iconcheck = 1;
- console.log('111', JSON.stringify(res.tempFilePaths));
- _self.params.media = res.tempFilePaths;
- console.log(_self.params.media);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- error: function(e) {
- console.log(e);
- }
- });
- },
-
- publish() {
- this.checkStatus = this.check_form();
- if(this.checkStatus){
- let _self = this;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- uni.showLoading({
- title: '请稍等'
- });
- setTimeout(function () {
- uni.hideLoading();
- }, 2000);
-
-
-
-
-
-
-
-
- setTimeout(() => {
- uni.redirectTo({
- url:'/pages/publish/publishsuccess/publishsuccess'
- })
- }, 2000);
- }
- },
-
- check_form() {
- console.log('this.params',this.params);
- if(this.params.type.length <= 0) {
- uni.showToast({icon:'none',title:`请填写类别!`,duration: 2000});
- return false;
- }
-
-
-
-
-
- if(this.params.title.length <= 0) {
- uni.showToast({icon:'none',title:`请填写标题!`,duration: 2000});
- return false;
- }
- if(this.params.brand.length <= 0) {
- uni.showToast({icon:'none',title:`请填写品牌!`,duration: 2000});
- return false;
- }
- if(this.params.price.length <= 0) {
- uni.showToast({icon:'none',title:`请填写零售价!`,duration: 2000});
- return false;
- }
- if(this.params.supplier.length <= 0) {
- uni.showToast({icon:'none',title:`请填写供应商!`,duration: 2000});
- return false;
- }
- if(this.params.placeoforigin.length <= 0) {
- uni.showToast({icon:'none',title:`请填写生产地!`,duration: 2000});
- return false;
- }
- if(this.params.specifications.length <= 0) {
- uni.showToast({icon:'none',title:`请填写规格!`,duration: 2000});
- return false;
- }
- if(this.params.shelflife.length <= 0) {
- uni.showToast({icon:'none',title:`请填写保质期!`,duration: 2000});
- return false;
- }
- if(this.params.date.length <= 0) {
- uni.showToast({icon:'none',title:`请填写生产日期!`,duration: 2000});
- return false;
- }
- if(this.params.packaging.length <= 0) {
- uni.showToast({icon:'none',title:`请填写包装!`,duration: 2000});
- return false;
- }
- if(this.params.productlabel.length <= 0) {
- uni.showToast({icon:'none',title:`请填写标签!`,duration: 2000});
- return false;
- }
- if(this.params.media.length <= 0) {
- uni.showToast({icon:'none',title:`请上传图片!`,duration: 2000});
- return false;
- }
- return true;
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- placeoforiginclick(name){
- this.params.placeoforigin = name;
- this.placeoforiginopen = false;
- this.showback();
- },
-
- openplaceoforigin(){
- this.placeoforiginopen = true;
- this.hideback();
- },
-
- specificationsclick(e){
-
- this.specificationsopen = false;
- this.showback();
- },
-
- openspecifications(){
- this.specificationsopen = true;
- this.hideback();
- },
-
- checkboxChange: function (e) {
- var items = this.specificationslist,
- values = e.detail.value;
- for (var i = 0, lenI = items.length; i < lenI; ++i) {
- const item = items[i]
- if(values.includes(item.value)){
- this.$set(item,'checked',true)
- }else{
- this.$set(item,'checked',false)
- }
- }
- this.params.specifications = e.detail.value;
- console.log(this.params.specifications);
- },
- resetcheckbox(){
- var items = this.specificationslist;
- for (var i = 0, lenI = items.length; i < lenI; ++i) {
- const item = items[i];
- this.$set(item,'checked',false)
- }
- this.params.specifications = [];
- // console.log(this.params.specifications);
- },
- //隐藏返回按钮
- hideback(){
-
-
- this.backtyep = 2;
- console.log(this.backtyep)
- },
-
- showback(){
-
-
- this.backtyep = 1;
- console.log(this.backtyep)
- },
-
- onBackPress(e){
- console.log(this.backtyep)
- if(this.backtyep == 2){
- this.placeoforiginopen = false;
- this.backtyep = 1;
- return true;
- };
- },
-
- chooseaddr(){
- let self = this;
- uni.chooseLocation({
- success: function (res) {
- self.params.myposition = res.address;
- console.log('位置名称:' + res.name);
- console.log('详细地址:' + res.address);
- console.log('纬度:' + res.latitude);
- console.log('经度:' + res.longitude);
- }
- });
- },
-
- searchplace(e){
- if(e.value){
- let place = this.placeoforiginlist.filter(function (value) {
- console.log(value.detailAddress);
- return value.detailAddress.includes(e.value);
- });
- console.log('place',place);
- this.placeoforiginlist = place;
- }else{
- this.placeoforiginlist = this.places;
- }
- }
-
-
- }
- }
- </script>
- <style >
- @import url("./publish.css");
- </style>
|