| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373 |
- <template>
- <view class="padding">
- <view class="text-white padding bg radius">
- <div style="color: red">新增商品默认库存为1000件,需要修改可点击操作批量修改库存</div>
- <u-form :model="shop" label-position="top">
- <u-form-item label="商品标题">
- <u-input v-model="shop.goodsName" placeholder="请填写商品标题" />
- <view class="btn_search" @click="handleSearch">查询</view>
- </u-form-item>
- <u-form-item label="商品分类">
- <u-input v-model="shop.classifyName" placeholder="请选择" :disabled="true" @click="getflshow()" />
- </u-form-item>
- <u-form-item label="商品标签">
- <!-- <u-input v-model="" placeholder="请填写" /> -->
- <view class="flex align-center flex-wrap margin-bottom-sm">
- <view v-for="(item, index) in goodsLabel" :key="index" class="btn flex align-center margin-top">
- <view>{{ item }}</view>
- <view class="margin-left-sm" @tap.stop="bindupdata(index)">x</view>
- </view>
- <view class="btns margin-top" @click="addtype1()">+添加</view>
- </view>
- </u-form-item>
- <u-form-item label="商品原价(选填)">
- <u-input v-model="shop.originalMoney" @input="ZheKouInput" placeholder="请填写" />
- </u-form-item>
- <u-form-item label="打包费(选填)">
- <u-input v-model="shop.packMoney" placeholder="请填写" />
- </u-form-item>
- <u-form-item label="商品售价">
- <u-input v-model="shop.goodsMoney" @input="ZheKouInput" placeholder="请填写" />
- </u-form-item>
- <view class="padding bg radius margin-tb" style="padding: 10px 0">
- <view>
- <view class="text-lg" style="color: #333">商品描述(选填)</view>
- <view class="margin-tb-sm">
- <u-input
- v-model="shop.goodsDescribe"
- type="textarea"
- height="200"
- placeholde="请描述一下您的特长"
- maxlengt="200"
- :clearable="false"
- style="background: #f5f5f5"
- />
- </view>
- </view>
- <view>
- <view class="text-lg margin-top-sm text-black">商品封面图</view>
- <view class="flex" style="overflow: hidden; flex-wrap: wrap">
- <view v-if="shop.goodsCover.length">
- <view class="margin-top flex margin-right-sm flex-wrap">
- <view class="flex" style="width: 200rpx; height: 200rpx; margin-right: 2rpx; position: relative">
- <image :src="shop.goodsCover" style="width: 100%; height: 100%" mode="aspectFill"></image>
- <view style="z-index: 9; position: absolute; top: -15rpx; right: -15rpx" @click="removeImgs()">
- <u-icon name="close-circle-fill" color="#FCD202" size="50rpx"></u-icon>
- </view>
- </view>
- </view>
- </view>
- <view class="margin-top" @click="addImage(1)" v-if="shop.goodsCover.length <= 0">
- <view style="width: 200rpx; height: 200rpx; background: #f4f5f6" class="flex justify-center align-center">
- <view>
- <view class="text-center">
- <image src="../static/addimg.png" style="width: 65rpx; height: 55rpx"></image>
- </view>
- <view class="text-center text-black">添加图片</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view>
- <view class="text-lg margin-top-sm text-black">商品轮播图(可多张)</view>
- <view class="flex" style="overflow: hidden; flex-wrap: wrap">
- <view v-if="goodsPicture.length">
- <view class="margin-top flex margin-right-sm flex-wrap">
- <view
- class="flex"
- style="width: 200rpx; height: 200rpx; margin-right: 2rpx; position: relative"
- v-for="(image, index) in goodsPicture"
- :key="index"
- >
- <image :src="image" style="width: 100%; height: 100%" mode="aspectFill"></image>
- <view style="z-index: 9; position: absolute; top: -15rpx; right: -15rpx" @click="removeImg(index, 'lb')">
- <u-icon name="close-circle-fill" color="#FCD202" size="50rpx"></u-icon>
- </view>
- </view>
- </view>
- </view>
- <view class="margin-top" @click="addImages(1)" v-if="goodsPicture.length < maxCount">
- <view style="width: 200rpx; height: 200rpx; background: #f4f5f6" class="flex justify-center align-center">
- <view>
- <view class="text-center">
- <image src="../static/addimg.png" style="width: 65rpx; height: 55rpx"></image>
- </view>
- <view class="text-center text-black">添加图片</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view>
- <view class="text-lg margin-top-sm text-black">商品详情图(可多张)(选填)</view>
- <view class="flex" style="overflow: hidden; flex-wrap: wrap">
- <view v-if="goodsParticularsPicture.length">
- <view class="margin-top flex margin-right-sm flex-wrap">
- <view
- class="flex"
- style="width: 200rpx; height: 200rpx; margin-right: 2rpx; position: relative"
- v-for="(image, index) in goodsParticularsPicture"
- :key="index"
- >
- <image :src="image" style="width: 100%; height: 100%" mode="aspectFill"></image>
- <view style="z-index: 9; position: absolute; top: -15rpx; right: -15rpx" @click="removeImg(index, 'sq')">
- <u-icon name="close-circle-fill" color="#FCD202" size="50rpx"></u-icon>
- </view>
- </view>
- </view>
- </view>
- <view class="margin-top" @click="addImages(2)" v-if="goodsParticularsPicture.length < maxCount">
- <view style="width: 200rpx; height: 200rpx; background: #f4f5f6" class="flex justify-center align-center">
- <view>
- <view class="text-center">
- <image src="../static/addimg.png" style="width: 65rpx; height: 55rpx"></image>
- </view>
- <view class="text-center text-black">添加图片</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- <view>
- <view class="text-lg margin-top-sm text-black">商品详情图(可多张)</view>
- <editor id="editor"
- style="height:350rpx;color: #000000;font-size: 28rpx;width: 100%;border: 2rpx solid #F0F0F0;padding: 16rpx;"
- placeholder="请输入商品详情" @ready="onEditorReady" @input="getText"></editor>
- </view>
- <view>
- <view class="margin-top" @click="addImages(2)" v-if="goodsParticularsPicture.length<=1">
- <view style="width: 200rpx;height: 200rpx;background: #f4f5f6;"
- class="flex justify-center align-center">
- <view>
- <view class="text-center">
- <image src="../static/addimg.png" style="width: 65rpx;height: 55rpx;">
- </image>
- </view>
- <view class="text-center text-black">添加图片</view>
- </view>
- </view>
- </view>
- </view> -->
- </view>
- <u-form-item label="规格类型">
- <u-input v-model="attrsType" placeholder="请选择" :disabled="true" @click="ggShow()" />
- </u-form-item>
- <u-form-item label="商品规格" v-if="attrsid == 2">
- <view style="width: 100%">
- <view style="display: flex; width: 100%">
- <u-input style="width: 80%" v-model="attrs" placeholder="请选择" :disabled="true" @click="openguige()" />
- <view style="width: 20%; text-align: right; color: #ff4701" v-if="attrs" @click="goGuiGeItem()">修改价格</view>
- </view>
- <view style="color: #ff4701; font-size: 24upx">*修改商品、商品售价后,商品规格将重置,请谨慎操作!</view>
- </view>
- </u-form-item>
- </u-form>
- </view>
- <u-button @click="submit" class="margin-top" :custom-style="customStyle" shape="square" :hair-line="false">提交</u-button>
- <!-- 规格弹框 -->
- <u-popup v-model="Guigeshow" mode="bottom" border-radius="14" :closeable="closeable">
- <view>
- <scroll-view scroll-y="true" style="max-height: calc(100vh - 120rpx)">
- <view class="padding">
- <view>规格类型</view>
- <view class="flex align-center margin-top-sm flex-wrap">
- <view class="" v-for="(item, indexs) in list" :key="indexs">
- <view class="btn margin-top-sm flex align-center flex-wrap" :class="listIndex == indexs ? 'boxH' : ''" @click="bindguige(indexs, 1, item.ruleName)">
- {{ item.ruleName }}
- </view>
- <!-- <view class="btns margin-top-sm" @click="addtype(1)">+添加</view> -->
- </view>
- </view>
- <view v-for="(name, index) in attrList.ruleValue" :key="index">
- <view class="margin-top-sm">{{ name.value }}</view>
- <view class="flex align-center flex-wrap margin-top-sm">
- <!-- :class="typeIndex1 == index&&typeIndex == ind?'active':''" -->
- <view class="btn margin-top-sm" v-for="(ite, ind) in name.detail1" :key="ind" @click="bindguige(ind, 2, name.detail, index)" v-if="name.detail1">
- {{ ite }}
- </view>
- <!-- <view class="btns margin-top-sm">+添加</view> -->
- </view>
- </view>
- </view>
- </scroll-view>
- <view class="addguige" @click="bindget()">确定</view>
- </view>
- </u-popup>
- <u-select v-model="flshow" :list="ClassifyList" valueName="classifyId" labelName="classifyName" @confirm="confirm"></u-select>
- <!-- 规格类型 -->
- <u-select v-model="ggshow" :list="attrList1" valueName="id" labelName="name" @confirm="ggconfirm"></u-select>
- <!-- 添加规格弹框 -->
- <u-popup v-model="show2" mode="center" border-radius="14" width="500rpx" height="300rpx" :closeable="closeable">
- <view>
- <view class="padding">
- <view>添加标签</view>
- <view>
- <u-input v-model="typeName" placeholder="请填写" />
- </view>
- </view>
- <view class="addguiges" @click="bindclose1()">确定</view>
- </view>
- </u-popup>
- <!-- 选择图片弹窗 -->
- <u-popup v-model="tupianShow" mode="center" border-radius="4">
- <view class="tupianPop">
- <view class="pop_header">
- 选择图片
- <u-icon name="close" color="#000" size="28" @click="handleClose"></u-icon>
- </view>
- <!-- 封面图区域 -->
- <view class="box_header">
- 封面图
- <text class="header_text">/ 共{{ totalCountFengmian }}条</text>
- </view>
- <view class="pop_box">
- <scroll-view class="box_body" enable-flex scroll-y @scrolltolower="scrolltolowerFengmian">
- <view class="img_box" v-for="item in fengmianList" :key="item.id" @click="clickItemFengmian(item)">
- <image class="images" :src="item.goodsCover" mode="aspectFill"></image>
- <view class="box_check" v-if="!item.isCheck"></view>
- <view v-else class="box_check_active">
- <u-icon name="checkmark" color="#fff" size="28"></u-icon>
- </view>
- </view>
- <view v-if="!fengmianList.length" class="">暂无数据</view>
- </scroll-view>
- </view>
- <!-- 轮播图区域 -->
- <view class="box_header">
- 轮播图
- <text class="header_text">/ 共{{ totalCountLunbo }}条</text>
- </view>
- <view class="pop_box">
- <scroll-view class="box_body" enable-flex scroll-y @scrolltolower="scrolltolowerLunbo">
- <view class="img_box" v-for="item in lunboList" :key="item.id" @click="clickItemLunbo(item)">
- <image class="images" :src="item.goodsPicture" mode="aspectFill"></image>
- <view class="box_check" v-if="!item.isCheck"></view>
- <view v-else class="box_check_active">
- <u-icon name="checkmark" color="#fff" size="28"></u-icon>
- </view>
- </view>
- <view v-if="!lunboList.length" class="">暂无数据</view>
- </scroll-view>
- </view>
- <!-- 详情图区域 -->
- <view class="box_header">
- 详情图
- <text class="header_text">/ 共{{ totalCountXiangqing }}条</text>
- </view>
- <view class="pop_box">
- <scroll-view class="box_body" enable-flex scroll-y @scrolltolower="scrolltolowerXiangqing">
- <view class="img_box" v-for="item in xiangqingList" :key="item.id" @click="clickItemXiangqing(item)">
- <image class="images" :src="item.goodsParticularsPicture" mode="aspectFill"></image>
- <view class="box_check" v-if="!item.isCheck"></view>
- <view v-else class="box_check_active">
- <u-icon name="checkmark" color="#fff" size="28"></u-icon>
- </view>
- </view>
- <view v-if="!xiangqingList.length" class="">暂无数据</view>
- </scroll-view>
- </view>
- <!-- 确认按钮区域 -->
- <view class="btn_pop" @click="handleConfrim">确认</view>
- </view>
- </u-popup>
- <!-- 用于图片压缩的canvas画布 -->
- <canvas
- :style="{
- width: cw + 'px',
- height: cw + 'px',
- position: 'absolute',
- zIndex: -1,
- left: '-10000rpx',
- top: '-10000rpx'
- }"
- canvas-id="zipCanvas"
- ></canvas>
- <!--画布结束-->
- </view>
- </template>
- <script>
- import configdata from '@/common/config.js'
- import getLessLimitSizeImage from '@/utils/imageCompress.js'
- export default {
- data() {
- return {
- shop: {
- goodsName: '',
- classifyId: '',
- classifyName: '',
- goodsLabel: [],
- attr: [],
- sku: [],
- originalMoney: '',
- packMoney: 0,
- goodsMoney: '',
- goodsDescribe: '',
- //详情图
- goodsCover: '',
- goodsPicture: [],
- goodsParticularsPicture: [],
- shopId: uni.getStorageSync('shopId')
- },
- shops: {
- goodsName: '',
- classifyId: '',
- classifyName: '',
- goodsLabel: [],
- attr: [],
- sku: [],
- originalMoney: '',
- packMoney: 0,
- goodsMoney: '',
- goodsDescribe: '',
- //详情图
- goodsCover: '',
- goodsPicture: [],
- goodsParticularsPicture: [],
- shopId: uni.getStorageSync('shopId')
- },
- attrs: '',
- goodsLabel: [],
- goodsPicture: [],
- goodsParticularsPicture: [],
- customStyle: {
- backgroundColor: '#FFCC00',
- color: '#000000',
- border: 0
- },
- status: 1,
- customStyle1: {
- color: '#000000',
- position: 'fixed',
- bottom: '15rpx',
- left: '0rpx',
- right: '0rpx',
- margin: '0rpx 50rpx',
- backgroundColor: '#FFCC00'
- },
- Guigeshow: false,
- //详情图
- goodsCover: [],
- shopId: '',
- page: 1,
- limit: 100,
- list: [],
- listIndex: 0,
- typeIndex: 0,
- typeIndex1: 0,
- wdIndex: 0,
- show: false,
- typeName: '',
- shows: false,
- typeperature: '',
- flshow: false,
- ggshow: false,
- ClassifyList: [],
- attrList: {},
- attrLists: [],
- shopId: '',
- show2: false,
- update: 0,
- maxCount: 4,
- editorCtx: '',
- htmlMessage: '',
- closeable: true,
- attrsType: '多规格',
- attrsid: 2,
- attrList1: [
- {
- name: '单规格',
- id: 1
- },
- {
- name: '多规格',
- id: 2
- }
- ],
- //画板边长默认是屏幕宽度,正方形画布
- cw: uni.getSystemInfoSync().windowWidth,
- tupianShow: false,
- fengmianList: [],
- currPageFengmian: 1,
- totalCountFengmian: 0,
- lunboList: [],
- currPageLunbo: 1,
- totalCountLunbo: 0,
- xiangqingList: [],
- currPageXiangqing: 1,
- totalCountXiangqing: 0
- }
- },
- onLoad(option) {
- console.log('option', option)
- if (option.goodsId) {
- this.update = 1
- uni.setNavigationBarTitle({
- title: '修改商品'
- })
- this.goodsDet(option.goodsId)
- } else {
- this.update = 0
- }
- // console.log(option, '店铺id')
- // this.shopId = option.shopId
- this.shopId = this.$queue.getData('shopId')
- this.getguige()
- // this.onEditorReady();
- },
- onShow() {
- let list = this.$queue.getData('guigeSelectItemList')
- if (list) {
- this.shop.sku = list
- this.$queue.remove('guigeSelectItemList')
- }
- this.getClassifyList()
- },
- methods: {
- handleConfrim() {
- let fmList = this.fengmianList.filter((ele) => ele.isCheck)
- let lbList = []
- this.lunboList.forEach((ele) => {
- if (ele.isCheck) {
- lbList.push(ele.goodsPicture)
- }
- })
- let xqList = []
- this.xiangqingList.forEach((ele) => {
- if (ele.isCheck) {
- xqList.push(ele.goodsParticularsPicture)
- }
- })
- console.log(fmList)
- console.log(lbList)
- console.log(xqList)
- this.tupianShow = false
- if (fmList.length) {
- this.shop.goodsCover = fmList[0].goodsCover
- }
- if (lbList.length) {
- this.goodsPicture = [...this.goodsPicture, ...lbList]
- }
- if (xqList.length) {
- this.goodsParticularsPicture = [...this.goodsParticularsPicture, ...xqList]
- }
- },
- clickItemFengmian(item) {
- if (item.isCheck) {
- item.isCheck = false
- } else {
- this.fengmianList.forEach((ele) => (ele.isCheck = false))
- item.isCheck = true
- }
- },
- clickItemLunbo(item) {
- let count = 0
- this.lunboList.forEach((ele) => {
- if (ele.isCheck) {
- count++
- }
- })
- if (item.isCheck) {
- item.isCheck = false
- } else {
- if (count >= this.maxCount - this.goodsPicture.length) {
- uni.showToast({
- title: '最多上传4张',
- icon: 'none'
- })
- } else {
- item.isCheck = true
- }
- }
- },
- clickItemXiangqing(item) {
- let count = 0
- this.xiangqingList.forEach((ele) => {
- if (ele.isCheck) {
- count++
- }
- })
- if (item.isCheck) {
- item.isCheck = false
- } else {
- if (count >= this.maxCount - this.goodsParticularsPicture.length) {
- uni.showToast({
- title: '最多上传4张',
- icon: 'none'
- })
- } else {
- item.isCheck = true
- }
- }
- },
- scrolltolowerFengmian() {
- if (this.totalCountFengmian > this.fengmianList.length) {
- this.currPageFengmian++
- this.getFengMian()
- } else {
- uni.showToast({
- title: '没有更多数据了',
- icon: 'none'
- })
- }
- },
- scrolltolowerLunbo() {
- if (this.totalCountLunbo > this.lunboList.length) {
- this.currPageLunbo++
- this.getLunBo()
- } else {
- uni.showToast({
- title: '没有更多数据了',
- icon: 'none'
- })
- }
- },
- scrolltolowerXiangqing() {
- if (this.totalCountXiangqing > this.xiangqingList.length) {
- this.currPageXiangqing++
- this.getXiangQing()
- } else {
- uni.showToast({
- title: '没有更多数据了',
- icon: 'none'
- })
- }
- },
- handleSearch() {
- if (!this.shop.goodsName) {
- uni.showToast({
- title: '请输入商户标题',
- icon: 'none'
- })
- return
- }
- this.fengmianList = []
- this.currPageFengmian = 1
- this.lunboList = []
- this.currPageLunbo = 1
- this.xiangqingList = []
- this.currPageXiangqing = 1
- this.tupianShow = true
- this.getFengMian()
- this.getLunBo()
- this.getXiangQing()
- },
- async getFengMian() {
- let data = {
- page: this.currPageFengmian,
- limit: 6,
- name: this.shop.goodsName
- }
- let res = await this.$Request.getA('/app/goods/goodsCoverList', data)
- // console.log(res)
- if (res.code == 0) {
- res.data.list.forEach((item) => {
- item.isCheck = false
- })
- this.fengmianList = [...this.fengmianList, ...res.data.list]
- this.totalCountFengmian = res.data.totalCount
- }
- },
- async getLunBo() {
- let data = {
- page: this.currPageLunbo,
- limit: 6,
- name: this.shop.goodsName
- }
- let res = await this.$Request.getA('/app/goods/goodsPictureList', data)
- // console.log(res)
- if (res.code == 0) {
- res.data.list.forEach((item) => {
- item.isCheck = false
- })
- this.lunboList = [...this.lunboList, ...res.data.list]
- this.totalCountLunbo = res.data.totalCount
- }
- },
- async getXiangQing() {
- let data = {
- page: this.currPageXiangqing,
- limit: 6,
- name: this.shop.goodsName
- }
- let res = await this.$Request.getA('/app/goods/goodsParticularsPictureList', data)
- // console.log(res)
- if (res.code == 0) {
- res.data.list.forEach((item) => {
- item.isCheck = false
- })
- this.xiangqingList = [...this.xiangqingList, ...res.data.list]
- this.totalCountXiangqing = res.data.totalCount
- }
- },
- handleClose() {
- this.tupianShow = false
- },
- ZheKouInput(e) {
- console.log(e)
- this.attrs = ''
- this.shop.attr = []
- if (this.attrsid == 1) {
- this.guigeclect()
- } else {
- this.getgoodslist()
- }
- },
- goGuiGeItem() {
- this.$queue.setData('guigeSelectItemList', this.shop.sku)
- uni.navigateTo({
- url: '/my/publish/guigeitem'
- })
- },
- //获取分类
- getflshow() {
- console.log(this.ClassifyList.length)
- if (this.ClassifyList.length == 0) {
- uni.navigateTo({
- url: '/my/store/fenlei'
- })
- } else {
- this.flshow = true
- }
- },
- // 规格类型
- ggShow() {
- this.ggshow = true
- },
- //获取商品规格列表
- getgoodslist() {
- let ruleValues = this.attrList.ruleValue
- for (var j = 0; j < ruleValues.length; j++) {
- let details = ruleValues[j].detail
- ruleValues[j].detail = ruleValues[j].detail.toString()
- }
- let data = {
- attrName: this.attrList.ruleName,
- attrValue: ruleValues,
- ruleId: this.attrList.id
- }
- this.$Request
- .postJsonBB(
- '/admin/goods/isFormatAttr',
- {
- coverImg: this.shop.goodsCover,
- originalPrice: this.shop.originalMoney,
- price: this.shop.goodsMoney
- },
- data
- )
- .then((res) => {
- if (res.code == 0) {
- // this.shop.sku.push(res.data.value)
- this.shop.sku = res.data.value
- console.log(res.data.value, '111', this.shop.sku)
- }
- })
- },
- //获取规格
- bindget() {
- this.getgoodslist()
- this.attrs = this.attrList.ruleName
- var obj = {}
- obj.attrName = this.attrList.ruleName
- obj.attrValue = this.attrList.ruleValue
- obj.ruleId = this.attrList.id
- this.shop.attr.push(obj)
- this.Guigeshow = false
- },
- //商品分类
- confirm(e) {
- // console.log(e)
- this.shop.classifyName = e[0].label
- this.shop.classifyId = e[0].value
- },
- //规格分类
- ggconfirm(e) {
- // console.log(e)
- this.attrsType = e[0].label
- this.attrsid = e[0].value
- if (e[0].value == 1) {
- this.shop.attr = []
- this.guigeclect()
- }
- },
- // 单规格
- guigeclect() {
- let data = {
- coverImg: this.shop.goodsCover,
- originalPrice: this.shop.originalMoney,
- price: this.shop.goodsMoney
- }
- this.$Request.getA('/admin/goods/onlyFormatAttr', data).then((res) => {
- if (res.code == 0) {
- // this.shop.sku.push(res.data.value)
- this.shop.sku = res.data.value
- console.log(res.data.value, '111', this.shop.sku)
- }
- })
- },
- addtype(index) {
- if (index == 1) {
- this.show = true
- } else if (index == 2) {
- this.shows = true
- }
- },
- bindclose() {
- if (index == 1) {
- this.show = false
- } else if (index == 2) {
- this.shows = false
- }
- },
- //弹框规格切换
- bindguige(index, e, name, index1) {
- // console.log(index, e, name)
- if (e == 1) {
- this.listIndex = index
- this.attrList = this.list[index]
- } else if (e == 2) {
- this.typeIndex = index
- this.typeIndex1 = index1
- } else if (e == 3) {
- this.wdIndex = index
- }
- },
- //规格弹框
- openguige() {
- if (!this.attrList.ruleValue) {
- uni.showToast({
- title: '暂无规格',
- icon: 'none',
- duration: 1000
- })
- return
- }
- // 打开规格选项弹框
- this.Guigeshow = true
- },
- //获取商品规格
- getguige() {
- let data = {
- // page: this.page,
- // limit: this.limit,
- shopId: this.shopId
- }
- this.$Request.getA('/selfGoodsRule/list', data).then((res) => {
- if (res.code == 0) {
- // this.shop.sku = res.data
- if (res.data.length > 0) {
- this.list = res.data
- this.list.forEach((res) => {
- res.ruleValue.forEach((ret) => {
- ret.detail = ret.detail.split(',')
- ret.detail1 = ret.detail
- })
- })
- console.log('this.attrList', this.list)
- this.attrList = this.list[0]
- if (this.shop.attr && this.shop.attr.length > 0) {
- for (var i in res.data) {
- if (this.shop.attr[0].ruleId == res.data[i].id) {
- this.attrs = res.data[i].ruleName
- }
- }
- }
- }
- }
- })
- },
- // 商品类型
- getClassifyList() {
- let data = {
- shopId: this.shopId
- }
- this.$Request.getA('/admin/goods/selectAllClassify', data).then((res) => {
- if (res.code == 0) {
- this.ClassifyList = res.data
- this.counts = this.ClassifyList[0].classifyId
- if (this.shop.classifyId != '') {
- for (var i in res.data) {
- if (this.shop.classifyId == res.data[i].classifyId) {
- this.shop.classifyName = res.data[i].classifyName
- }
- }
- }
- }
- })
- },
- getStarttime(e) {
- console.log(e)
- console.log(this.shop)
- this.shop.openTime = e.hour + ':' + e.minute
- },
- getEndtime(e) {
- console.log(e)
- this.shop.closeTime = e.hour + ':' + e.minute
- },
- // 详情图删除
- removeImg(index, texts) {
- if (texts == 'lb') {
- this.goodsPicture.splice(index, 1)
- } else if (texts == 'sq') {
- this.goodsParticularsPicture.splice(index, 1)
- }
- },
- // 身份证 资格证删除
- removeImgs() {
- // if (index == 1) {
- this.shop.goodsCover = ''
- // }
- },
- bindOpen(e) {
- console.log(e)
- let that = this
- uni.chooseLocation({
- success: function (res) {
- console.log('位置名称:' + res.name)
- console.log('详细地址:' + res.address)
- console.log('纬度:' + res.latitude)
- console.log('经度:' + res.longitude)
- that.shop.detailedAddress = res.address
- that.shop.shopLat = res.latitude
- that.shop.shopLng = res.longitude
- }
- })
- },
- // 图片上传
- addImages(e) {
- let num = 0
- if (e == 1) {
- num = this.maxCount - this.goodsPicture.length
- }
- if (e == 2) {
- num = this.maxCount - this.goodsParticularsPicture.length
- }
- let that = this
- uni.chooseImage({
- count: num,
- sourceType: ['album', 'camera'],
- success: (res) => {
- for (let i = 0; i < res.tempFiles.length; i++) {
- //这里的id和页面中写的html代码的canvas的id要一致
- let canvasId = 'zipCanvas'
- //原图的路径
- let imagePath = res.tempFiles[i].path
- //大小限制
- let limitSize = 1024 * 2
- //初始绘画区域是画布自身的宽度也就是屏幕宽度
- let drawWidth = uni.getSystemInfoSync().windowWidth
- let that = this
- let token = uni.getStorageSync('shopToken')
- getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
- // uni.showLoading({
- // title: '上传中'
- // })
- uni.uploadFile({
- url: that.config('APIHOST1') + '/admin/new-file/upload',
- filePath: resPath,
- header: {
- token: token
- },
- name: 'file',
- success: (uploadFileRes) => {
- console.log(uploadFileRes, 'l')
- if (e == 1) {
- if (that.goodsPicture.length < 6) {
- that.goodsPicture.push(JSON.parse(uploadFileRes.data).data)
- }
- } else if (e == 2) {
- if (that.goodsParticularsPicture.length < 6) {
- that.goodsParticularsPicture.push(JSON.parse(uploadFileRes.data).data)
- }
- console.log(that.goodsParticularsPicture)
- }
- uni.hideLoading()
- },
- fail: () => {
- uni.showToast({
- title: '上传失败',
- icon: 'error'
- })
- }
- })
- })
- }
- }
- })
- },
- // 图片上传
- addImage(e) {
- let that = this
- uni.chooseImage({
- count: 1,
- sourceType: ['album', 'camera'],
- success: (res) => {
- for (let i = 0; i < res.tempFiles.length; i++) {
- //这里的id和页面中写的html代码的canvas的id要一致
- let canvasId = 'zipCanvas'
- //原图的路径
- let imagePath = res.tempFiles[i].path
- //大小限制
- let limitSize = 1024 * 2
- //初始绘画区域是画布自身的宽度也就是屏幕宽度
- let drawWidth = uni.getSystemInfoSync().windowWidth
- let that = this
- let token = uni.getStorageSync('shopToken')
- getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
- // uni.showLoading({
- // title: '上传中'
- // })
- uni.uploadFile({
- url: that.config('APIHOST1') + '/admin/new-file/upload',
- filePath: resPath,
- header: {
- token: token
- },
- name: 'file',
- success: (uploadFileRes) => {
- console.log(uploadFileRes, 'l')
- if (e == 1) {
- that.shop.goodsCover = JSON.parse(uploadFileRes.data).data
- }
- uni.hideLoading()
- },
- fail: () => {
- uni.showToast({
- title: '上传失败',
- icon: 'error'
- })
- }
- })
- })
- }
- }
- })
- },
- 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
- },
- // 发布
- submit() {
- this.shop.goodsPicture = this.goodsPicture
- this.shop.goodsPicture = this.goodsPicture.toString()
- this.shop.goodsParticularsPicture = this.goodsParticularsPicture.toString()
- this.shop.goodsLabel = this.goodsLabel.toString()
- if (!this.shop.goodsName) {
- uni.showToast({
- title: '请填写商品标题',
- icon: 'none',
- duration: 1000
- })
- return
- }
- if (!this.shop.classifyName) {
- uni.showToast({
- title: '请选择商品分类',
- icon: 'none',
- duration: 1000
- })
- return
- }
- if (!this.shop.goodsLabel) {
- uni.showToast({
- title: '请填写商品标签',
- icon: 'none',
- duration: 1000
- })
- return
- }
- if (!this.shop.originalMoney) {
- this.shop.originalMoney = this.shop.goodsMoney
- // uni.showToast({
- // title: '请填写商品原价',
- // icon: 'none',
- // duration: 1000
- // })
- // return
- }
- // console.log(this.shop.packMoney,'------------')
- // if (this.shop.packMoney*1 != '') {
- // uni.showToast({
- // title: '请填写商品打包费',
- // icon: 'none',
- // duration: 1000
- // })
- // return
- // }
- if (!this.shop.goodsMoney) {
- uni.showToast({
- title: '请填写商品售价',
- icon: 'none',
- duration: 1000
- })
- return
- }
- if (!this.shop.goodsDescribe) {
- this.shop.goodsDescribe = '无'
- // uni.showToast({
- // title: '请填写商品描述',
- // icon: 'none',
- // duration: 1000
- // })
- // return
- }
- if (!this.shop.goodsCover) {
- uni.showToast({
- title: '请上传商品封面图',
- icon: 'none',
- duration: 1000
- })
- return
- }
- if (!this.shop.goodsPicture) {
- uni.showToast({
- title: '请上传商品轮播图',
- icon: 'none',
- duration: 1000
- })
- return
- }
- if (!this.shop.goodsParticularsPicture) {
- this.goodsParticularsPicture = [this.Tupian('/xiangqing/12ecc56005731327e02f42f0d851848.png')]
- // uni.showToast({
- // title: '请上传商品详情图',
- // icon: 'none',
- // duration: 1000
- // })
- // return
- }
- if (this.attrsid == 2) {
- if (this.shop.attr.length == 0) {
- uni.showToast({
- title: '请选择商品规格',
- icon: 'none',
- duration: 1000
- })
- return
- }
- }
- let shops = this.shop
- for (var i = 0; i < shops.attr.length; i++) {
- let attrValues = shops.attr[i].attrValue
- for (var j = 0; j < attrValues.length; j++) {
- let details = attrValues[j].detail
- let detailss = ''
- for (var z = 0; z < details.length; z++) {
- detailss = detailss + details[z]
- }
- shops.attr[i].attrValue[j].detail = detailss
- }
- }
- if (this.update == 0) {
- var url = '/admin/goods/insertGoods'
- }
- if (this.update == 1) {
- var url = '/admin/goods/update'
- }
- this.$Request.postJsonA(url, shops).then((res) => {
- if (res.code == 0) {
- uni.showToast({
- title: '操作成功',
- icon: 'none'
- })
- setTimeout(function () {
- uni.navigateBack()
- }, 1000)
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- }
- })
- },
- //删除规格
- bindupdata(index) {
- console.log('this.shop.goodsLabel', typeof this.goodsLabel)
- this.goodsLabel.splice(index, 1)
- },
- addtype1() {
- this.typeName = ''
- this.show2 = true
- },
- bindclose1() {
- if (!this.typeName) {
- uni.showToast({
- title: '请填写规格',
- icon: 'none',
- duration: 1000
- })
- return
- }
- this.goodsLabel.push(this.typeName)
- this.show2 = false
- },
- // 获取商铺详情
- goodsDet(goodsId) {
- let data = {
- goodsId: goodsId
- }
- this.$Request.getA('/admin/goods/selectGoodsById', data).then((res) => {
- if (res.code == 0) {
- this.dataCentre = res.data
- this.shop = res.data
- this.getClassifyList()
- if (this.shop.goodsLabel) {
- this.goodsLabel = this.shop.goodsLabel.split(',')
- }
- if (this.shop.goodsPicture) {
- this.goodsPicture = this.shop.goodsPicture.split(',')
- }
- if (this.shop.goodsParticularsPicture) {
- this.goodsParticularsPicture = this.shop.goodsParticularsPicture.split(',')
- }
- if (res.data.attr.length == 0) {
- this.attrsid = 1
- this.attrsType = '单规格'
- } else {
- this.attrsid = 2
- this.attrsType = '多规格'
- }
- this.getguige()
- }
- })
- }
- }
- }
- </script>
- <style>
- page {
- background-color: #f5f5f5;
- }
- .bg {
- background-color: #ffffff;
- }
- .btn {
- border: 1upx solid #cccccc;
- border-radius: 10px;
- padding: 0rpx 30rpx;
- margin-right: 25rpx;
- height: 30px;
- line-height: 30px;
- }
- .boxH {
- background: #fcd202;
- border: none;
- }
- .btns {
- border: 1upx dashed #333333;
- border-radius: 28px;
- padding: 0rpx 35rpx;
- margin-right: 25rpx;
- height: 30px;
- line-height: 30px;
- }
- .active {
- background: #fcd202;
- border: none;
- }
- .actives {
- background: #fcd202;
- border: none;
- }
- .addguige {
- width: 90%;
- margin: 0 auto 25rpx;
- background: #fcd202;
- box-shadow: 0px 10upx 20upx 0px #ffd9b3;
- border-radius: 16upx;
- text-align: center;
- height: 88upx;
- line-height: 88upx;
- /* position: fixed;
- bottom: 25upx;
- left: 0;
- right: 0; */
- }
- .addguiges {
- width: 90%;
- margin: 0 auto;
- background: #fcd202;
- box-shadow: 0px 10upx 20upx 0px #ffd9b3;
- border-radius: 16upx;
- text-align: center;
- height: 88upx;
- line-height: 88upx;
- /* position: fixed;
- bottom: 25upx;
- left: 0;
- right: 0; */
- }
- .u-input__textarea {
- background-color: #f5f5f5 !important;
- padding: 10rpx !important;
- }
- .btn_search {
- display: flex;
- align-items: center;
- justify-content: center;
- margin-top: 20rpx;
- width: 200rpx;
- height: 80rpx;
- color: #fff;
- border-radius: 10rpx;
- background-color: #3e8ef7;
- }
- .tupianPop {
- width: 672rpx;
- height: 95vh;
- overflow-y: auto;
- }
- .pop_header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 20rpx;
- height: 70rpx;
- font-size: 32rpx;
- font-weight: bold;
- background-color: #f5f9ff;
- }
- .pop_box {
- padding: 0 20rpx;
- height: 20vh;
- }
- .box_header {
- padding: 0 20rpx;
- height: 70rpx;
- line-height: 70rpx;
- font-size: 28rpx;
- font-weight: bold;
- }
- .header_text {
- margin-left: 18rpx;
- color: #666666;
- }
- .box_body {
- display: flex;
- flex-wrap: wrap;
- height: 20vh;
- }
- .img_box {
- position: relative;
- margin-right: 55rpx;
- margin-top: 35rpx;
- width: 150rpx;
- height: 187rpx;
- border-radius: 8rpx;
- }
- .images {
- width: 100%;
- height: 100%;
- border-radius: 8rpx;
- }
- .box_check {
- position: absolute;
- top: -25rpx;
- right: -25rpx;
- width: 50rpx;
- height: 50rpx;
- border-radius: 50%;
- border: 2rpx solid #808080;
- background-color: #fff;
- }
- .box_check_active {
- position: absolute;
- top: -25rpx;
- right: -25rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- width: 50rpx;
- height: 50rpx;
- border-radius: 50%;
- background-color: #ff8d1a;
- }
- .btn_pop {
- display: flex;
- align-items: center;
- justify-content: center;
- margin: 20rpx auto;
- width: 626rpx;
- height: 90rpx;
- font-size: 32rpx;
- color: #fff;
- border-radius: 115rpx;
- background-color: #f18731;
- }
- </style>
|