Browse Source

产品相关流程

devlop
mo-bai 4 years ago
parent
commit
5be6886174
13 changed files with 354 additions and 153 deletions
  1. 11
      App.vue
  2. 12
      apis/deviceApi.js
  3. 45
      apis/productionApi.js
  4. 8
      enums/index.js
  5. 27
      pages/device-info/index.vue
  6. 29
      pages/login/index.vue
  7. 25
      pages/mall/index.vue
  8. 42
      pages/production-info/index.vue
  9. 130
      pages/production-operation/index.vue
  10. 5
      pages/promotion/Banner.vue
  11. 146
      pages/promotion/index.vue
  12. 2
      store/index.js
  13. 25
      utils/hook.js

11
App.vue

@ -1,14 +1,21 @@
<script>
import { go2 } from '@/utils/hook.js'
import { go2, changeTabbar } from '@/utils/hook.js'
import { isString } from '@/utils/is.js'
import store from '@/store/index.js'
import handlePushMsg from '@/utils/handlePushMsg.js'
import { checkUpdate } from '@/apis/commonApi.js'
import { enterpriseType } from '@/enums/index.js'
export default {
onLaunch: function () {
const token = store.state.qnToken
if (token) {
go2('digital-workshops')
const type = store.state.companyInfo.enterpriseType
changeTabbar(type)
if (type == enterpriseType.PERSONAL) {
go2('mall')
} else {
go2('digital-workshops')
}
}
// #ifdef APP-PLUS
this.createPushEvent()

12
apis/deviceApi.js

@ -89,3 +89,15 @@ export function getAccessToken(data = {}) {
data
})
}
/**
* 删除设备
* @param {object} data
* @property {array} idList string[]
*/
export function removeDevice(data = {}) {
return http.post({
url: `/base-paper-trading/delete/mechanical-equipment/by/ids`,
data
})
}

45
apis/productionApi.js

@ -0,0 +1,45 @@
import http from '../utils/http/index.js'
/**
* 获取产品列表
*/
export function getProductionList(data = {}) {
return http.get({
url: '/base-paper-trading/get/packagingProduct/list',
data
})
}
/**
* 添加或修改产品
*/
export function changeProduction(data = {}) {
return http.post({
url: '/base-paper-trading/save/packagingProduct',
data
})
}
/**
* 删除产品
* @param {object} data
* @property {array} idList string[]
*/
export function removeProduction(data = {}) {
return http.post({
url: '/base-paper-trading/delete/packagingProduct/by/ids',
data
})
}
/**
* 获取产品详情
* @param {object} data
* @property {string} id
*/
export function getProductionInfo(data = {}) {
return http.get({
url: `/base-paper-trading/get/packagingProduct/${data.id}`,
data
})
}

8
enums/index.js

@ -5,8 +5,16 @@ export const XAPPID = '503258978847966407'
export const H5_URL = `https://printpackage${urlEnv}.qniao.cn`
/**
* h5端分享设备地址
*/
export const H5_URL_DEVICE = `${H5_URL}/#/pages/certification/index?`
/**
* h5端分享工厂地址
*/
export const H5_URL_FACTORY = `${H5_URL}/#/pages/factory-inspection/index?`
// 统一支付接口
export const PAY_URL = `https://api-client-psc${urlEnv}.qniao.cn/payment-settlement-center/pay`

27
pages/device-info/index.vue

@ -34,13 +34,13 @@
<script>
import { go2, back } from '@/utils/hook.js'
import { getEquipmentInfo } from '@/apis/deviceApi.js'
import { getEquipmentInfo, removeDevice } from '@/apis/deviceApi.js'
export default {
data() {
return {
info: { imgItemList: [] },
id: null,
swiperCurrent: 1
swiperCurrent: 0
}
},
onLoad(options) {
@ -71,7 +71,28 @@ export default {
})
},
//
deleteDevice() {}
deleteDevice() {
uni.showModal({
title: '提示',
content: '确定要删除该设备吗?',
success: (res) => {
if (res.confirm) {
removeDevice({ idList: [this.id] }).then((res) => {
if (res) {
uni.showToast({
title: '删除成功',
icon: 'success',
duration: 2000
})
setTimeout(() => {
back()
}, 2000)
}
})
}
}
})
}
}
}
</script>

29
pages/login/index.vue

@ -19,7 +19,7 @@
<uni-easyinput v-model="captcha" :inputBorder="false" :placeholderStyle="'font-size:32rpx;'" placeholder="请输入验证码" :maxlength="6" type="number" />
<view v-show="timer > 0" class="timer_area">
<text class="timer">{{ `(${timer}S后) ` }}</text>
<text class="timer_text">重新获取</text>
<text class="timer_text" @click="getCode">重新获取</text>
</view>
<text v-show="timer <= 0" class="code" @click="getCode">获取验证码</text>
</view>
@ -40,9 +40,10 @@
<script>
import { getAuthCaptcha, loginByPhone, getQnToken } from '@/apis/loginApi'
import { getBaseInfo, pushCustomerBind } from '@/apis/commonApi'
import { accountType, verificationType, codePurpose } from '@/enums/index.js'
import { accountType, verificationType, codePurpose, enterpriseType } from '@/enums/index.js'
import store from '@/store/index.js'
import { go2, back } from '@/utils/hook.js'
import { go2, back, changeTabbar } from '@/utils/hook.js'
import { validateField } from '@/utils/index.js'
export default {
data() {
return {
@ -69,16 +70,14 @@ export default {
},
//
getCode() {
if (this.phoneNumber.trim() === '') {
let rules = [
{ required: true, message: '请输入手机号' },
{ type: 'phone', message: '请输入正确的手机号' }
]
const { isValid, msg } = validateField(this.phoneNumber, rules)
if (!isValid) {
uni.showToast({
title: '请输入手机号码',
icon: 'none'
})
return
}
if (this.phoneNumber.trim().length !== 11) {
uni.showToast({
title: '请输入正确的手机号码',
title: msg,
icon: 'none'
})
return
@ -162,6 +161,12 @@ export default {
if (!res.enterpriseList || res.enterpriseList.length === 0) {
go2('select-role')
} else {
// //
let type = this.$store.state.companyInfo.enterpriseType
if (type == enterpriseType.PERSONAL) {
page.url = 'mall'
}
changeTabbar(type)
go2(page.url, page.data, page.isRedirect)
}
}

25
pages/mall/index.vue

@ -3,7 +3,30 @@
</template>
<script>
export default {}
import { enterpriseType } from '@/enums/index.js'
export default {
created() {
// //
// let type = this.$store.state.companyInfo.enterpriseType
// if (type == enterpriseType.PERSONAL) {
// // 广
// this.changeTabbar(0, false)
// this.changeTabbar(1, false)
// } else {
// // 广
// this.changeTabbar(0, true)
// this.changeTabbar(1, true)
// }
},
methods: {
changeTabbar(index, isShow) {
uni.setTabBarItem({
index: index,
visible: isShow
})
}
}
}
</script>
<style></style>

42
pages/production-info/index.vue

@ -1,6 +1,6 @@
<template>
<view class="content">
<uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="授信记录"></uni-nav-bar>
<uni-nav-bar left-icon="back" @clickLeft="back" statusBar fixed title="产品信息"></uni-nav-bar>
<view class="flex-col group_4">
<view class="flex-col group_5">
<view class="flex-col items-center group_6">
@ -14,17 +14,17 @@
</view>
</view>
<view class="flex-col section_1">
<text class="text_5">{{ info.name || '设备' }}</text>
<text class="text_5">{{ info.name || '产品' }}</text>
<text class="text_6">
{{ info.machineDescribe || '没有描述' }}
{{ info.produceDescribe || '没有描述' }}
</text>
</view>
</view>
<view class="flex-row section_2">
<view class="flex-col items-center text-wrapper_1" @click="deleteDevice">
<view class="flex-col items-center text-wrapper_1" @click="deleteProduction">
<text>删除</text>
</view>
<view class="flex-col items-center text-wrapper_2" @click="go2('device-operation', { operation: 'edit', id: info.id })">
<view class="flex-col items-center text-wrapper_2" @click="go2('production-operation', { operation: 'edit', id: info.id })">
<text>编辑</text>
</view>
</view>
@ -34,13 +34,13 @@
<script>
import { go2, back } from '@/utils/hook.js'
import { getEquipmentInfo } from '@/apis/deviceApi.js'
import { getProductionInfo, removeProduction } from '@/apis/productionApi.js'
export default {
data() {
return {
info: { imgItemList: [] },
id: null,
swiperCurrent: 1
swiperCurrent: 0
}
},
onLoad(options) {
@ -50,7 +50,7 @@ export default {
},
onShow() {
if (this.id) {
getEquipmentInfo({ id: this.id }).then((res) => {
getProductionInfo({ id: this.id }).then((res) => {
if (res) {
this.info = res
}
@ -71,7 +71,31 @@ export default {
})
},
//
deleteDevice() {}
deleteProduction() {
uni.showModal({
title: '提示',
content: '确定删除当前产品?',
success: (res) => {
if (res.confirm) {
removeProduction({ idList: [this.id] }).then((res) => {
if (res) {
uni.showToast({
title: '删除成功',
icon: 'success',
duration: 2000,
mask: true,
success: () => {
setTimeout(() => {
back()
}, 2000)
}
})
}
})
}
}
})
}
}
}
</script>

130
pages/production-operation/index.vue

@ -5,7 +5,7 @@
<view class="flex-col group_9">
<view class="flex-row group_10">
<text class="text_18">*</text>
<text class="text_19">设备图片</text>
<text class="text_19">产品图片</text>
<text class="tip">(图片单张大小不超过2M数量最多5张)</text>
</view>
<view class="flex-row">
@ -23,7 +23,7 @@
<view class="justify-between group">
<view class="flex-row">
<text class="text_1">*</text>
<text class="text_2">设备名称</text>
<text class="text_2">产品名称</text>
</view>
<qn-easyinput
:maxlength="20"
@ -31,98 +31,24 @@
:inputBorder="false"
text="right"
placeholderStyle="fontSize: 28rpx"
placeholder="请输入设备名称"
placeholder="请输入产品名称"
></qn-easyinput>
</view>
<view class="divider"></view>
<view class="justify-between group">
<view class="flex-row">
<text class="text_2">设备类型</text>
</view>
<view style="width: 400rpx; z-index: 2">
<qn-select
:placeholderStyle="placeholderStyle"
contentStyle="background: none; padding: 0;text-align: right;"
:options="deviceTypeList"
v-model="form.type"
placeholder="请选择设备类型"
></qn-select>
</view>
</view>
<view class="divider"></view>
<view class="justify-between group">
<view class="flex-row">
<text class="text_2">生产工艺</text>
</view>
<view style="width: 400rpx; z-index: 1">
<qn-select
:placeholderStyle="placeholderStyle"
contentStyle="background: none; padding: 0;text-align: right;"
:options="technicsTypeList"
v-model="form.technicsTypeList"
placeholder="请选择设备支持的生产类型"
multiple
></qn-select>
</view>
</view>
<view class="divider"></view>
<view class="group">
<view class="flex-row">
<text class="text_1">*</text>
<text class="text_2">设备描述</text>
<text class="text_2">产品描述</text>
</view>
<qn-easyinput
:maxlength="200"
v-model="form.machineDescribe"
v-model="form.produceDescribe"
type="textarea"
placeholderStyle="fontSize: 28rpx "
placeholder="请输入设备介绍"
placeholder="请输入产品介绍"
style="background-color: rgb(247, 248, 250); margin-top: 16rpx"
></qn-easyinput>
</view>
<view class="divider"></view>
<view class="justify-between group">
<view class="flex-row">
<text class="text_2">摄像头ID</text>
</view>
<qn-easyinput
:maxlength="20"
v-model="form.cameraId"
:inputBorder="false"
text="right"
placeholderStyle=" fontSize: 28rpx"
placeholder="请输入摄像头ID"
></qn-easyinput>
</view>
<view class="divider"></view>
<view class="justify-between group">
<view class="flex-row">
<text class="text_2">摄像头渠道号</text>
</view>
<qn-easyinput
:maxlength="20"
v-model="form.channelNum"
:inputBorder="false"
text="right"
type="number"
placeholderStyle=" fontSize: 28rpx"
placeholder="请输入摄像头渠道号"
></qn-easyinput>
</view>
<view class="divider"></view>
<view class="justify-between group">
<view class="flex-row">
<text class="text_2">云盒ID</text>
</view>
<qn-easyinput
:maxlength="20"
v-model="form.cloudBoxId"
:inputBorder="false"
text="right"
placeholderStyle=" fontSize: 28rpx"
placeholder="请输入云盒ID"
></qn-easyinput>
</view>
</view>
<qn-footer fixed>
<view class="flex-col items-center text-wrapper_1" @click="save">
@ -136,7 +62,7 @@
import { go2, back, uploadImage } from '@/utils/hook.js'
import { validateField } from '@/utils/index.js'
import { fileType } from '@/enums/index.js'
import { getDeviceTypeList, getTechnicsList, changeDevice, getEquipmentInfo } from '@/apis/deviceApi.js'
import { changeProduction, getProductionInfo } from '@/apis/productionApi.js'
const validateFields = [
{
@ -148,7 +74,7 @@ const validateFields = [
rules: [{ required: true, message: '请输入设备名称' }]
},
{
name: 'machineDescribe',
name: 'produceDescribe',
rules: [{ required: true, message: '请输入设备描述' }]
}
]
@ -161,16 +87,9 @@ export default {
form: {
id: null,
imgItemList: [],
machineDescribe: '',
cameraId: '',
channelNum: '',
cloudBoxId: '',
name: '',
type: '',
technicsTypeList: []
produceDescribe: '',
name: ''
},
deviceTypeList: [],
technicsTypeList: [],
placeholderStyle: 'font-size: 28rpx;font-weight:400;'
}
},
@ -194,18 +113,6 @@ export default {
})
}
},
created() {
getDeviceTypeList().then((res) => {
if (res) {
this.deviceTypeList = res.map((item) => ({ label: item.name, value: item.id }))
}
})
getTechnicsList().then((res) => {
if (res) {
this.technicsTypeList = res.map((item) => ({ label: item.name, value: item.id }))
}
})
},
methods: {
go2,
back,
@ -214,12 +121,11 @@ export default {
},
//
init(id) {
getEquipmentInfo({ id }).then((res) => {
getProductionInfo({ id }).then((res) => {
if (res) {
Object.keys(this.form).forEach((key) => {
this.form[key] = res[key]
})
this.form.technicsTypeList = res.technicsTypeList.map((item) => item.id)
}
})
},
@ -260,19 +166,7 @@ export default {
return false
}
}
if (this.form.cameraId) {
if (!this.form.channelNum) {
uni.showToast({
title: '请输入摄像头渠道号',
icon: 'none'
})
return false
}
}
let list = this.technicsTypeList.filter((item) => this.form.technicsTypeList.includes(item.value))
let technicsTypeList = list.map((item) => ({ id: item.value, name: item.label }))
this.form.typeName = this.deviceTypeList.find((item) => item.value == this.form.type).label
changeDevice({ ...this.form, technicsTypeList }).then((res) => {
changeProduction({ ...this.form }).then((res) => {
if (res) {
uni.showToast({
title: '保存成功',

5
pages/promotion/Banner.vue

@ -11,7 +11,7 @@
</view>
</swiper-item>
</swiper>
<image src="/static/imgs/general/share-gray-icon.png" class="image_1" />
<image @click="shareFactory" src="/static/imgs/general/share-gray-icon.png" class="image_1" />
<view class="flex-col items-center text-wrapper">
<text>{{ swiperCurrent + 1 }}/{{ list.length }}</text>
</view>
@ -63,6 +63,9 @@ export default {
current: url,
urls: urls
})
},
shareFactory() {
this.$emit('share')
}
}
}

146
pages/promotion/index.vue

@ -9,7 +9,7 @@
<image src="/static/imgs/general/share-black-icon.png" class="image" />
</view>
</view>
<Banner :list="swiperList"></Banner>
<Banner :list="swiperList" @share="popupShow"></Banner>
<view class="flex-col group_3">
<view class="flex-col section_1">
<view class="flex-col">
@ -59,11 +59,40 @@
</view>
</view>
</view>
<view v-if="curTab == 'production'">
<view class="grid">
<view class="flex-col grid-item" v-for="production in productionList" :key="production.id" @click="go2('production-info', { id: production.id })">
<text>{{ production.name }}</text>
<image mode="aspectFit" :src="production.imgItemList[0].url" class="image_7" />
</view>
</view>
</view>
<view class="observer">{{ hasMore ? '加载中~' : '没有更多~' }}</view>
</view>
<image @click="addItem" src="/static/imgs/promotion/add-icon.png" class="image_6" />
</view>
</view>
<uni-popup ref="popup" type="bottom">
<view class="flex-col section_6">
<text class="text_13">立即分享给好友</text>
<view class="flex-col group_20">
<view class="justify-between group_21">
<view class="flex-col items-center" @click="share('WXSceneSession')">
<image src="/static/imgs/general/session-share-icon.png" class="image_14" />
<text class="text_14">微信好友</text>
</view>
<view class="flex-col group_23" @click="share('WXSceneTimeline')">
<image src="/static/imgs/general/line-share-icon.png" class="image_15" />
<text class="text_15">朋友圈</text>
</view>
</view>
<view class="section_7"></view>
<view class="flex-col items-center button" @click="popupHide">
<text>取消</text>
</view>
</view>
</view>
</uni-popup>
</view>
</template>
@ -72,6 +101,7 @@ import Banner from './Banner.vue'
import { go2 } from '@/utils/hook.js'
import { getFactoryInfo } from '@/apis/factoryApi.js'
import { getEquipmentList } from '@/apis/deviceApi.js'
import { getProductionList } from '@/apis/productionApi.js'
import { fileType } from '@/enums/index.js'
export default {
components: {
@ -190,14 +220,14 @@ export default {
})
}
if (this.curTab == 'production') {
getEquipmentList({ ...this.pagination }).then((res) => {
getProductionList({ ...this.pagination }).then((res) => {
if (res) {
if (res.current <= 1) {
this.deviceList = res.records
this.productionList = res.records
} else {
this.deviceList = this.deviceList.concat(res.records)
this.productionList = this.productionList.concat(res.records)
}
this.hasMore = this.deviceList.length < res.total
this.hasMore = this.productionList.length < res.total
}
})
}
@ -219,6 +249,29 @@ export default {
if (this.curTab == 'production') {
go2('production-operation', { operation: 'add' })
}
},
popupShow() {
this.$refs.popup.open('bottom')
},
popupHide() {
this.$refs.popup.close()
},
shareFactory(scene) {
uni.share({
provider: 'weixin',
type: 0,
title: factoryInfo.name,
summary: '印包客支持远程验厂,在线了解工厂',
scene: scene, // WXSceneTimeline,WXSceneSession
imageUrl: 'https://qncloud.oss-cn-shenzhen.aliyuncs.com/paper_shopkeeper/wx-share-store.png',
href: H5_URL_FACTORY + `shareId=${res}`,
success: () => {
console.log('分享成功')
},
fail: (err) => {
console.log('err', err)
}
})
}
}
}
@ -404,4 +457,87 @@ export default {
}
}
}
.section_6 {
padding-top: 40rpx;
overflow: hidden;
border-radius: 40rpx 40rpx 0px 0px;
background-color: rgb(255, 255, 255);
height: 408rpx;
.text_13 {
align-self: center;
color: rgb(51, 51, 51);
font-size: 28rpx;
font-weight: 500;
line-height: 40rpx;
white-space: nowrap;
}
.group_20 {
margin-top: 40rpx;
.group_21 {
padding: 0 48rpx 32rpx;
color: rgb(51, 51, 51);
font-size: 24rpx;
line-height: 33rpx;
white-space: nowrap;
.group_23 {
width: 494rpx;
.image_15 {
width: 96rpx;
height: 96rpx;
}
.text_15 {
margin-left: 12rpx;
margin-top: 16rpx;
}
}
.image_14 {
border-radius: 50%;
width: 96rpx;
height: 96rpx;
}
.text_14 {
margin-top: 16rpx;
}
}
.section_7 {
background-color: rgb(247, 248, 250);
height: 16rpx;
}
.button {
padding: 26rpx 0;
color: rgb(51, 51, 51);
font-size: 32rpx;
line-height: 45rpx;
white-space: nowrap;
background-color: rgb(255, 255, 255);
}
}
}
.grid {
padding: 20rpx 32rpx 91rpx;
width: 750rpx;
color: rgb(31, 31, 31);
font-size: 28rpx;
font-weight: 500;
line-height: 40rpx;
white-space: nowrap;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-row-gap: 22rpx;
grid-column-gap: 16rpx;
.grid-item {
padding: 24rpx 20rpx 20rpx;
border-radius: 10rpx;
filter: drop-shadow(0px 5rpx 11rpx #00000014);
background-color: rgb(255, 255, 255);
background-position: 0px 0px;
background-size: 100% 100%;
background-repeat: no-repeat;
.image_7 {
margin-top: 20rpx;
width: 296rpx;
height: 296rpx;
}
}
}
</style>

2
store/index.js

@ -12,7 +12,7 @@ let qnToken = null,
userInfo = null,
/**
* @value id 企业id
* @value enterpriseType 企业类型
* @value enterpriseType 企业类型 印刷包装厂 2 供应商 5 个人 8
* @value name 企业名称
* @value fddEnterpriseStatus 法大大认证状态 1未认证2认证进行中3认证成功4认证失败
*/

25
utils/hook.js

@ -1,5 +1,5 @@
import store from '@/store/index'
import { uploadUrl, XAPPID } from '@/enums/index.js'
import { uploadUrl, XAPPID, enterpriseType } from '@/enums/index.js'
import { pushCustomerOff } from '@/apis/commonApi'
// 框架方法封装
const tabList = ['digital-workshops', 'promotion', 'mall', 'mine']
@ -15,6 +15,29 @@ export function tab2(tabPage) {
})
}
}
/**
* 根据用户角色动态改变tabbar
* @param {number} type 企业类型
* @return {null}
*/
export function changeTabbar(type) {
if (type == enterpriseType.PERSONAL) {
;[0, 1].forEach((index) => {
uni.setTabBarItem({
index: index,
visible: false
})
})
} else {
;[0, 1].forEach((index) => {
uni.setTabBarItem({
index: index,
visible: true
})
})
}
}
/**
* @param {string} 返回上一级
* @return {null}

Loading…
Cancel
Save