123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820 |
- <template>
- <view class="pages">
- <form @submit="formSubmit" @reset="formReset">
- <view class="form-item-type nomal-top">
- <view class="form-item required">
- <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 required">
- <view class="form-item-til">名称</view>
- <view class="form-item-con">
- <input type="text" placeholder="请输入发布产品名称" v-model="params.name" value="" />
- </view>
- </view>
- <view class="form-item required arrow" @click="openbrand">
- <view class="form-item-til">品牌</view>
- <view class="form-item-con">
- <input type="text" placeholder="请输入品牌" v-model="params.brandName" value="" />
- </view>
- </view>
- <view class="form-item required">
- <view class="form-item-til">供应商</view>
- <view class="form-item-con">
- <input type="text" disabled placeholder="" v-model="params.compName" value="" />
- </view>
- </view>
- <view class="form-item required arrow" @click="openplaceoforigin">
- <view class="form-item-til">生产地</view>
- <view class="form-item-con">
- <input type="text" disabled="disabled" placeholder="" v-model="params.placeOfProduction" value="" />
- </view>
- </view>
-
- <view class="form-item required">
- <view class="form-item-til">规格</view>
- <view class="form-item-con">
- {{item}}
- <input type="text" placeholder="" v-model="params.spec" 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" placeholder="请输入市场价" v-model="params.originalPrice" 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.qualityGuaranteePeriod" value="" />
- </view>
- </view>
- <view class="form-item">
- <view class="form-item-til">生产日期</view>
- <view class="form-item-con">
- <picker mode="date" :value="params.dateOfManufacture" :start="startDate" :end="endDate" @change="bindDateChange">
- <view class="uni-input">{{params.dateOfManufacture}}</view>
- </picker>
-
- </view>
- </view>
- <view class="form-item">
- <view class="form-item-til">商品介绍</view>
- <view class="form-item-con" style="text-align: left;">
-
- <textarea placeholder="请输入商品介绍" v-model="params.description" auto-height />
-
- </view>
- </view>
- <view class="form-item">
- <view class="form-item-til">商品货号</view>
- <view class="form-item-con">
- <input type="text" placeholder="请输入商品货号" v-model="params.productSn" 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.unit" 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.sort" 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">
- <view class="img-item" v-for="(item,index) in pics" :key="index" >
- <icon type="cancel" @click="delImg(index)" size="26"/>
- <image :src="item" @click="previewPic(index)" class="choosedIMG" ></image>
- </view>
- </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)" class="simplepage-item">{{item.detailAddress}}</view>
- </scroll-view>
- </view>
-
-
- <view class="placeoforigin-page fix-content translate" :class="{ 'open':brandopen }" >
- <view class="search-wrap search-left-color">
- <view class="search">
- <view class="searchTxt">
- <uni-search-bar placeholder="搜索品牌关键词" @confirm="searchbrand" @input="searchbrand" ></uni-search-bar>
- </view>
- </view>
- </view>
-
- <scroll-view class="simplepage-wrap" scroll-y="true">
- <view v-for="(item,index) in brandlist" :key="index" @click="brandclick(item)" class="simplepage-item">{{item.brandName}}</view>
- </scroll-view>
- </view>
-
-
- <view class="spec-page fix-content translate" :class="{ 'open': specopen }" >
- <view class="spec-wrap wrap">
- <checkbox-group @change="checkboxChange">
- <label v-for="(item,index) in speclist" :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="specclick">确定</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: '暂无相关数据'
- }
- },
- thetoken:'',
- params: {
- token: '',
- type:'',
- myposition:'',
- name:'',
- brandName:'',
- brandId:'',
- price:'',
- originalPrice:'',
- compName:'默认的供应商',
- compId:'',
- placeOfProduction:'',
- spec:'',
- qualityGuaranteePeriod:'',
- dateOfManufacture: currentDate,
- unit:'',
- productlabel:'',
- albumPics:'',
- pic:'',
- productBigCategoryId:'',
- productCategoryId:'',
- productCategoryName:'',
- productBigCategoryName:'',
- placeOfProductionId:0,
- publishStatus:"0",
- productSn:'',
- sort:'',
- description:'',
- },
- pics:[],
-
- checkStatus:false,
-
- supplieropen:false,
- supplierlist:[],
-
- placeoforiginopen:false,
- placeoforiginlist:[],
- brandopen:false,
- brandlist:[],
- places:[],
- brands:[],
-
- specopen:false,
- speclist:[
- {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;
- this.params.productBigCategoryId = bus.data.parentId;
- this.params.productCategoryId = bus.data.id;
- this.params.productBigCategoryName = bus.data.productBigCategoryName;
- this.params.productCategoryName = 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;
-
- }
- });
-
-
- this.thetoken = this.params.tokenhead+this.params.token;
- uni.getStorage({
- key:'userInfo',
- success: function (res) {
- self.params.compId = res.data.company.compId;
- self.params.compName = res.data.company.compName;
-
- }
- });
- this.$api.http.get(this.config.apiBaseurl+'/company/cp/detail',{header: {Authorization:this.thetoken},params:{compId:this.params.compId}}).then(res =>{
- console.log('res',JSON.parse(JSON.stringify(res)));
- this.placeoforiginlist = res.data.data.origines;
- this.brandlist = res.data.data.brands;
- this.brands = res.data.data.brands;
- this.places = res.data.data.origines;
- this.params.compName= 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.dateOfManufacture = 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({
-
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success: function(res) {
- console.log('res111',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));
-
-
-
- const isLt10M = res.tempFiles[0].size / 1024 / 1024 < 10;
- if(!isLt10M) {
- uni.showToast({
- title: "上传文件大小不能超过 10MB!",
- icon:'none'
- })
- return false;
- };
- const imgNumber = _self.pics.length<5;
- if(!imgNumber) {
- uni.showToast({
- title: "图片不能超过5张!",
- icon:'none'
- })
- return false;
- };
-
-
- let obj = new Object();
- let file=[];
- obj.name = "file";
- obj.uri = res.tempFiles[0].path;
- file.push(obj);
- _self.uploadTheImg(file);
- },
- error: function(e) {
- console.log(e);
- }
- });
- },
- uploadTheImg(imgFiles){
- let _self = this;
-
- uni.uploadFile({
- url: _self.config.apiBaseurl + '/upload/fileImg',
- fileType: "image",
- files:imgFiles,
-
- name: 'file',
- formData: {
-
-
- },
- header: {
-
-
- Accept:'*/*',
- Authorization: 'Bearer '+ _self.params.token,
- },
- success: (res) => {
- console.log(JSON.parse(res.data))
- let data = JSON.parse(res.data);
- _self.pics.push(data.data);
- if (res.statusCode == 200) {
- uni.showToast({
- icon: 'success',
- title: "添加成功...",
- })
- }
-
- },
- error(error) {
- uni.showToast({
- title: "添加失败...",
- })
- }
- });
- },
- previewPic(index){
-
- uni.previewImage({
- urls: this.pics,
- current:index,
- longPressActions: {
- success: function(data) {
- console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
- },
- fail: function(err) {
- console.log(err.errMsg);
- }
- }
- });
-
- },
-
- delImg(index){
- console.log('index',index);
- console.log('t',this.pics);
- this.pics.splice(index,1);
- console.log('t',this.pics);
- },
-
- publish() {
- this.params.albumPics = this.pics.toString();
- this.params.pic = this.pics[0];
- this.checkStatus = this.check_form();
- if(this.checkStatus){
- let _self = this;
- uni.showLoading({
- title: '请稍等'
- });
- this.$api.http.post(this.config.apiBaseurl+'/prod/pub/add',this.params,{
- header: {
- Accept:'application/json',
- Authorization: 'Bearer '+ this.params.token,
- }
- }).then(res => {
- uni.hideLoading();
- console.log('res',res);
- if(res.data.message =='暂未登录或token已经过期'){
-
-
- uni.showToast({
- title:res.data.message,
- duration: 2000
- });
- setTimeout(() => {
- window.location.replace(this.config.loginUrl);
- }, 2000);
- };
- if(res.data.code!=200){
- uni.showToast({
- icon:"none",
- title:res.data.message,
- duration: 2000
- });
- return false;
- };
- uni.showToast({
- icon:'success',
- title:`发布成功,请等待审核!`,
- duration: 2000
- });
- setTimeout(() => {
- uni.redirectTo({
- url:'/pages/publish/publishsuccess/publishsuccess'
- })
- }, 2000);
- }).catch(err => {
- uni.hideLoading();
- console.log(err)
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- },
-
- 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.name.length <= 0) {
- uni.showToast({icon:'none',title:`请填写商品名称!`,duration: 2000});
- return false;
- }
- if(this.params.brandName.length <= 0) {
- uni.showToast({icon:'none',title:`请填写品牌!`,duration: 2000});
- return false;
- }
-
-
-
-
- if(this.params.compName.length <= 0) {
- uni.showToast({icon:'none',title:`请填写供应商!`,duration: 2000});
- return false;
- }
- if(this.params.placeOfProduction.length <= 0) {
- uni.showToast({icon:'none',title:`请填写生产地!`,duration: 2000});
- return false;
- }
- if(this.params.spec.length <= 0) {
- uni.showToast({icon:'none',title:`请填写规格!`,duration: 2000});
- return false;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if(this.params.albumPics.length <= 0) {
- uni.showToast({icon:'none',title:`请上传图片!`,duration: 2000});
- return false;
- }
- return true;
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- placeoforiginclick(item){
- console.log('placeoforiginclick',item);
- this.params.placeOfProduction = item.detailAddress;
- this.params.placeOfProductionId = item.id;
- this.placeoforiginopen = false;
- this.showback();
- },
-
- openplaceoforigin(){
- this.placeoforiginopen = true;
- this.hideback();
- },
-
- brandclick(brand){
-
- this.params.brandName = brand.brandName;
- this.params.brandId = brand.brandId;
- this.brandopen = false;
- this.showback();
- },
-
- openbrand(){
- this.brandopen = true;
- this.hideback();
- },
-
- specclick(e){
-
- this.specopen = false;
- this.showback();
- },
-
- openspec(){
- this.specopen = true;
- this.hideback();
- },
-
- checkboxChange: function (e) {
- var items = this.speclist,
- 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.spec = e.detail.value;
- console.log(this.params.spec);
- },
- resetcheckbox(){
- var items = this.speclist;
- for (var i = 0, lenI = items.length; i < lenI; ++i) {
- const item = items[i];
- this.$set(item,'checked',false)
- }
- this.params.spec = [];
-
- },
-
- hideback(){
-
-
- this.backtyep = 2;
- console.log(this.backtyep)
- },
-
- showback(){
-
-
- this.backtyep = 1;
-
- },
-
- onBackPress(e){
-
- 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;
- }
- },
-
- searchbrand(e){
- console.log('品牌',e);
- if(e.value){
- let brand = this.brandlist.filter(function (value) {
- console.log(value);
- return value.brandName.includes(e.value);
- });
- console.log('brand',brand);
- this.brandlist = brand;
- }else{
- this.brandlist = this.brands;
- }
- }
-
-
- }
- }
- </script>
- <style >
- @import url("./publish.css");
- </style>
|