Commit 69dfa2fc authored by 郭晓清's avatar 郭晓清
parents ddf765bf 69a7565a
......@@ -5,7 +5,8 @@ const UNI_APP = {
// banshou: 'https://m.banshou.com', //扳手app
},
systemUrl: {
apiUrl: 'http://192.168.1.22', //java端域名请求头
// apiUrl: 'http://192.168.1.22', //java端域名请求头
apiUrl: 'http://apidoc.banshouhui.com:3000/mock/31', // mock端域名请求头
},
qn_base_url: 'https://qn-static.banshouhui.com/self-support/'
}
......
......@@ -5,7 +5,8 @@ const UNI_APP = {
banshou: 'https://m.test.ibanshou.cn', //扳手app
},
systemUrl: {
apiUrl: 'https://system.dev.banshouhui.com', //java端域名请求头
// apiUrl: 'https://system.dev.banshouhui.com', //java端域名请求头
apiUrl: 'http://apidoc.banshouhui.com:3000/mock/31', // mock端域名请求头
},
qn_base_url: 'https://qn-static.banshouhui.com/self-support/'
}
......
......@@ -2,6 +2,7 @@
import "./../.env.js";
import { AnalysysAgent } from "@/utils/analysys_paas.js";
import util from "@/utils/util.js";
import login from "@/utils/login.js";
export default {
globalData: {
// 开发环境
......@@ -73,16 +74,19 @@ export default {
}
},
},
onLaunch: function () {
onLaunch: async function () {
// 应用初始化(全局只触发一次)
AnalysysAgent.registerSuperProperty("platform", "self-support");
this.getSystemInfo()
// 版本更新
this.updateApp();
},
onShow: function () {
onShow: async function () {
// 应用启动,或从后台进入前台显示
this.autoLogin();
// 等待自动授权登录接口调用结束
await this.autoLogin();
},
onHide: function () {
// 应用从前台进入后台
......@@ -129,48 +133,38 @@ export default {
},
/**
* 用户自动登录
* 微信用户自动登录
*/
autoLogin() {
async autoLogin() {
let that = this;
uni.login({
async success(res) {
if (res.code) {
let params = {
code: res.code,
wxAppNo: that.globalData.wxAppNo, // 自营平台小程序
};
let result = await that.$u.api.loginWechatAuth(params);
if (result) {
if (result.code == 200 && result.data) {
that.setUserData(result.data);
}
} else {
uni.showModal({
title: "请求失败",
content: result.message,
showCancel: false,
});
}
uni.hideLoading();
} else {
uni.showModal({
title: "登录失败",
content: "未获取到code",
});
}
},
fail() {},
});
await login.oauth().then(async res => {
if (res.code) {
let params = {
code: res.code,
wxAppNo: that.globalData.wxAppNo, // 自营平台小程序
};
let result = await that.$u.api.loginWechatAuth(params)
if (result && result.code == 200 && result.data) {
that.setUserData(result.data);
}
} else {
uni.showModal({
title: "登录失败",
content: "未获取到code",
});
}
})
},
setUserData(userInfo) {
if (userInfo && userInfo.token) {
// 如果已经登录则直接获取相关信息
util.setOpenid(userInfo.wxopenid);
this.$u.vuex('vuex_token', userInfo.token);
uni.setStorageSync("user-info", userInfo);
this.$u.vuex('vuex_user', userInfo);
this.$u.vuex('vuex_wx_uid', userInfo.wxopenid);
} else {
this.$u.vuex('vuex_token', '');
this.$u.vuex('vuex_user', null);
this.$u.vuex('vuex_wx_uid', '');
}
},
......
......@@ -12,8 +12,10 @@ let learnApiFun = function(vm){
let ChapterDetails = async (params = {}) => await vm.$u.get(collegeApiUrl+'/v1/chapter-sections',params);
/* 获取课程节信息*/
let CourseSection = async (params = {}) => await vm.$u.get(collegeApiUrl+'/v1/section-details',params);
/* 更新学习情况*/
let updateLearnCourses = async (params = {}) => await vm.$u.post(collegeApiUrl+'/v1/update-learn-courses',params);
const learnApi = {
getTrainingNoticeList,CourseList,ChapterDetails,CourseSection
getTrainingNoticeList,CourseList,ChapterDetails,CourseSection,updateLearnCourses
}
return learnApi
}
......
import util from '@/utils/util.js'
let orderApiFun = function(vm){
let listByRecommendOrder = async (params = {}) => await vm.$u.get('/wxh-worker-rest/rest/recommend/order', params);
/**
* 工单数量查询接口
*/
let listOrderCount = async (params = {}) => await vm.$u.get('http://apidoc.banshouhui.com:3000/mock/31/wxh-worker-rest/rest/'+ vm.vuex_token+'/order/queryOrdersCount/V2', params);
let listOrderCount = async (params = {}) => await vm.$u.get('/wxh-worker-rest/rest/'+ vm.vuex_token+'/order/queryOrdersCount/V2', params);
/**
* 工单列表接口 http://apidoc.banshouhui.com:3000/mock/31/wxh-worker-rest/rest/order/revision/{token}/list
*/
let listOrder = async (params = {}) => await vm.$u.get('http://apidoc.banshouhui.com:3000/mock/31/wxh-worker-rest/rest/order/revision/'+ vm.vuex_token+'/list', params);
let listOrder = async (params = {}) => await vm.$u.get('/wxh-worker-rest/rest/'+ vm.vuex_token+'/order/revision/list', params);
/**
* 获取师傅的预约日历
*/
let workerCalendar = async (params = {}) => await vm.$u.get('http://apidoc.banshouhui.com:3000/mock/31/wxh-worker-rest/rest/'+ vm.vuex_token+'/wokerOrder/appointment/calendar', params);
let workerCalendar = async (params = {}) => await vm.$u.get('/wxh-worker-rest/rest/'+ vm.vuex_token+'/wokerOrder/appointment/calendar', params);
/**
* 师傅预约
*/
let workerAppointment = async (params = {}) => await vm.$u.post('http://apidoc.banshouhui.com:3000/mock/31/wxh-worker-rest/rest/order/traceAndAppointment/traceOrder/'+ vm.vuex_token+'/order/{orderId}', params,{'content-type': 'application/x-www-form-urlencoded'});
let workerAppointment = async (params = {}) => await vm.$u.post('/wxh-worker-rest/rest/order/traceAndAppointment/traceOrder/'+ vm.vuex_token+'/order/{orderId}', params,{'content-type': 'application/x-www-form-urlencoded'});
// 联系顾客时间更新接口,暂时没有
/**
* 师傅签到接口
*/
let maintainWorkerCheckin = async (params = {},orderId) => await vm.$u.post('http://apidoc.banshouhui.com:3000/mock/31/wxh-worker-rest/rest/'+ vm.vuex_token+'/order/'+orderId+'/maintainWorkerCheckin', params,{'content-type': 'application/x-www-form-urlencoded'});
let maintainWorkerCheckin = async (params = {},orderId) => await vm.$u.post(prefix + '/wxh-worker-rest/rest/'+ vm.vuex_token+'/order/'+orderId+'/maintainWorkerCheckin', params,{'content-type': 'application/x-www-form-urlencoded'});
/**
* 订单详情查询
*/
let orderDetail = async (params = {}) => await vm.$u.get('http://apidoc.banshouhui.com:3000/mock/31/wxh-worker-rest/rest/order/revision/'+ vm.vuex_token+'/'+params.orderId, params);
let orderDetail = async (params = {}) => await vm.$u.get('/wxh-worker-rest/rest/order/revision/'+ vm.vuex_token+'/'+params.orderId, params);
/* 过程反馈查询接口 */
let feedbackConfig = async (params = {}) => await vm.$u.get('/wxh-worker-rest/rst/order/v2/getFeedBack/' + vm.vuex_token, params)
/**
* 查询工单操作记录列表接口
*/
let listOrderRecord = async (params = {}) => await vm.$u.get('http://apidoc.banshouhui.com:3000/mock/31/wxh-worker-rest/rest/order/record/'+ vm.vuex_token+'/listOrderRecord/'+params.orderId, params);
let listOrderRecord = async (params = {}) => await vm.$u.get('/wxh-worker-rest/rest/order/record/'+ vm.vuex_token+'/listOrderRecord/'+params.orderId, params);
/**
* 接单
*/
let orderAccept= async (params = {},orderId) => await vm.$u.get('http://apidoc.banshouhui.com:3000/mock/31/wxh-worker-rest/rest/'+ vm.vuex_token+'/order/'+orderId+'/accept', params);
let orderAccept= async (params = {},orderId) => await vm.$u.get('/wxh-worker-rest/rest/'+ vm.vuex_token+'/order/'+orderId+'/accept', params);
/**
* 抢单
*/
let orderGan = async (params = {},orderId) => await vm.$u.post('http://apidoc.banshouhui.com:3000/mock/31/wxh-worker-rest/rest/order/revision/applets/'+ vm.vuex_token+'/order/acceptAppletsOrder', params,{'content-type': 'application/x-www-form-urlencoded'});
let orderGan = async (params = {},orderId) => await vm.$u.post('/wxh-worker-rest/rest/order/revision/applets/'+ vm.vuex_token+'/order/acceptAppletsOrder', params,{'content-type': 'application/x-www-form-urlencoded'});
const orderApi = {
......@@ -58,7 +61,9 @@ let orderApiFun = function(vm){
orderDetail,
listOrderRecord,
orderAccept,
orderGan
orderGan,
maintainWorkerCheckin,
feedbackConfig
}
return orderApi
}
......
......@@ -40,7 +40,6 @@ const install = (Vue, vm) => {
// toLoginPage()
// return false
// }
// // const token = app && app.globalData && app.globalData.token || ''
if(config.url.indexOf('access-token=')>=0 && config.params['access-token']){
// 给默认参数增加access-token (Java端)
if(reg.test(config.url)){
......@@ -55,7 +54,6 @@ const install = (Vue, vm) => {
}
// config.header.token = vm.vuex_token || 'RTOKENe56f873b5823477fa2e15572f8fa7eb3a5fb6f7b';
config.header['x-requested-with'] = 'xmlhttprequest';
return config;
}
......@@ -94,13 +92,7 @@ const install = (Vue, vm) => {
message:msg
};
case 401:
//需要登录的接口,当token 过期时,清掉本地token,到登录页面
// if (!token) {
// uni.navigateTo({
// url: '/pages/login/index'
// });
// return;
// }
// token失效,跳转登录
toLoginPage()
case 403://没有权限访问
case 500:
......
page {
background-color: #fafafa;
background-color: #f4f5f7;
}
::-webkit-scrollbar {
......
......@@ -185,7 +185,7 @@
}]
},
buttonDisabled() {
return this.orderData.orderStatus == 4 || this.orderData.orderStatus == 6
return this.orderType == 4 || this.orderType == 6
},
dizhiImage() {
return process.uniEnv.qn_base_url + 'shouye-dizhi.png'
......@@ -266,7 +266,8 @@
display: flex;
align-items: center;
.tag-view {
.tag-view {
text-align: center;
width: 84rpx;
height: 40rpx;
color: #FFFFFF;
......@@ -286,7 +287,8 @@
}
}
.right-view {
.right-view {
text-align: center;
width: 100rpx;
height: 40rpx;
background-color: #F4F5F7;
......@@ -360,7 +362,8 @@
display: flex;
align-items: center;
.bottom-tag-view {
.bottom-tag-view {
text-align: center;
width: 52rpx;
height: 52rpx;
border-radius: 26rpx;
......
<template>
<view :class="['content', {'fixed': fixed}]">
<u-navbar :is-back="false" :is-fixed="false" :background="{ background: 'transparent' }" :border-bottom="false">
<text class="title-view">{{title}}</text>
</u-navbar>
<slot></slot>
</view>
</template>
<script>
export default {
props: {
title: {
type: String,
default: '充电桩自营平台'
},
fixed: {
type: Boolean,
default: false
}
},
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.content {
height: 100vh;
background-color: #f4f5f7;
padding: 0rpx 30rpx 0 30rpx;
overflow-y: auto;
&.fixed {
display: flex;
flex-direction: column;
}
.title-view {
color: #333333;
font-weight: bold;
font-size: 40rpx;
}
}
</style>
{
"easycom": {
"^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"
"easycom": {
"autoscan": true,
"custom": {
"^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"
}
},
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{
......@@ -14,7 +17,9 @@
{
"path": "pages/order/index",
"style": {
"navigationBarTitleText": "订单"
"navigationBarTitleText": "订单",
"navigationStyle": "custom",
"disableScroll": true
}
},
{
......@@ -201,13 +206,61 @@
"navigationStyle": "custom"// 隐藏系统导航栏
}
}
},
{
"path": "pages/photo/index",
"style": {
"navigationBarTitleText": "拍照小工具",
"navigationBarBackgroundColor":"#FFFFFF",
"backgroundColor":"#F4F5F7"
}
},
{
"path": "pages/photo/setting",
"style": {
"navigationBarTitleText": "水印设置",
"navigationBarBackgroundColor":"#FFFFFF",
"backgroundColor":"#F4F5F7"
// "navigationBarBackgroundColor": "#333333",
// "navigationBarTextStyle": "#FFFFFF",
// "disableScroll": true
}
},
{
"path": "pages/photo/take",
"style": {
"navigationStyle":"custom",
"navigationBarTitleText": "拍照",
"navigationBarBackgroundColor": "#333333",
"navigationBarTextStyle": "#FFFFFF",
"disableScroll": true
}
},
{
"path": "pages/photo/preview",
"style": {
"navigationBarTitleText": "照片预览",
"navigationBarBackgroundColor":"#333333",
"backgroundColor":"#FFFFFF",
"navigationBarTextStyle":"white"
}
},
{
"path": "pages/photo/list",
"style": {
"navigationBarTitleText": "规范展示",
"navigationBarBackgroundColor":"#FFFFFF",
"backgroundColor":"#F4F5F7"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
"backgroundColor": "#F4F5F7"
},
"tabBar": {
"color": "#7A7E83",
......@@ -249,6 +302,16 @@
"path": "pages/index/index", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
},
{
"name": "订单列表", //模式名称
"path": "pages/order/index", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
},
{
"name": "拍照小工具", //模式名称
"path": "pages/photo/index", //启动页面,必选
"query": "" //启动参数,在页面的onLoad函数里面得到
},
{
"name": "入驻首页",
"path": "pages/settle/index",
......
<template>
<view class="content">
<!-- <view style="width: 700rpx; height: 800rpx"> -->
<!-- <view class="title-view">充电桩自营平台</view> -->
<u-navbar :is-back="false" :is-fixed="false" :background="{ background: 'transparent' }" :border-bottom="false">
<text class="title-view">充电桩自营平台</text>
</u-navbar>
<!-- <u-swiper
:height="240"
:list="list"
:indicator-pos="indicatorPos"
:mode="mode"
:interval="3000"
@click="clickSwiper"
>
</u-swiper> -->
<TabBarPage title="充电桩自营平台">
<image class="banner-image" :src="bannerImage"></image>
<view class="msg-view">
......@@ -66,23 +52,24 @@
</view>
<!-- </view> -->
<!-- </scroll-view> -->
<view class="bottom-view">
<view class="bottom-view" v-if="needSettled || orderList.length <= 0">
<view class="bottom-line-view"></view>
<view class="bottom-text">我也是有底线哒</view>
<view class="bottom-line-view"></view>
</view>
</view>
</TabBarPage>
</template>
<script>
import util from "@/utils/util.js";
import TabBarPage from "@/components/tabBarList/index.vue"
const app = getApp();
import OrderCell from "@/components/order/index.vue";
export default {
components: {
OrderCell,
TabBarPage
},
data() {
return {
......@@ -102,12 +89,13 @@
pageNumber: 0,
pageSize: 10,
},
bottomLoading: false,
bottomLoading: false
};
},
watch: {
vuex_token(val) {
// 监听token变化,如果更新则重新加载页面数据
vuex_token(val, oldVal) {
// 监听token变化,如果更新则重新加载页面数据
console.log('', val, oldVal)
val && this.initSettleInfo()
}
},
......@@ -142,10 +130,11 @@
// 每次进入页面都刷新入驻状态
if (this.vuex_token) {
this.initSettleInfo();
} else {
// 初始化订单数据
this.loadOrderList();
}
// else {
// // 初始化订单数据
// this.loadOrderList();
// }
},
onPullDownRefresh() {
console.log('------下拉刷新------')
......@@ -194,6 +183,8 @@
});
},
loadOrderList() {
console.log('-----------准备加载推荐列表-----------')
return
let self = this;
// 加载订单列表
self.search.token = self.vuex_token;
......@@ -208,21 +199,6 @@
}
});
},
onRefresh() {
if (this._freshing) return;
this._freshing = true;
// 获取入驻状态
this.initSettleInfo();
// 获取推荐订单及数量
// ....
setTimeout(() => {
// 数据加载完成更新入驻状态和推荐列表
this.triggered = false;
this._freshing = false;
}, 1000);
},
onRestore() {
this.triggered = "restore";
},
......@@ -294,82 +270,70 @@
</script>
<style lang="scss" scoped>
.content {
height: 100vh;
background-color: #f4f5f7;
padding: 0rpx 30rpx 0 30rpx;
overflow-y: auto;
.banner-image {
width: 730rpx;
height: 280rpx;
margin-left: -14rpx;
}
.title-view {
.msg-view {
.msg-title {
color: #333333;
font-size: 32rpx;
font-weight: bold;
font-size: 40rpx;
padding: 1rpx 0rpx 30rpx 0rpx;
}
.banner-image {
width: 730rpx;
height: 280rpx;
margin-left: -14rpx;
.msg-list-view {
border-radius: 12rpx;
background-color: #ffffff;
padding: 12rpx 30rpx;
height: 252rpx;
}
.msg-view {
.msg-title {
color: #333333;
font-size: 32rpx;
font-weight: bold;
padding: 1rpx 0rpx 30rpx 0rpx;
}
.msg-list-view {
border-radius: 12rpx;
background-color: #ffffff;
padding: 12rpx 30rpx;
height: 252rpx;
}
.msg-content {
color: #333333;
font-size: 26rpx;
.msg-content {
color: #333333;
font-size: 26rpx;
.msg-content-view {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20rpx;
margin-bottom: 20rpx;
.msg-content-view {
.left-view {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20rpx;
margin-bottom: 20rpx;
.left-view {
display: flex;
align-items: center;
.msg-icon {
width: 80rpx;
height: 36rpx;
margin-right: 20rpx;
}
.msg-text {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
width: 448rpx;
}
.msg-icon {
width: 80rpx;
height: 36rpx;
margin-right: 20rpx;
}
.right-icon {
width: 14rpx;
height: 24rpx;
.msg-text {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
width: 448rpx;
}
}
.line-view {
height: 2rpx;
background-color: #f4f5f7;
.right-icon {
width: 14rpx;
height: 24rpx;
}
}
.line-view {
height: 2rpx;
background-color: #f4f5f7;
}
}
}
.logo {
height: 200 rpx;
width: 100%;
......@@ -452,7 +416,7 @@
font-size: 28rpx;
padding: 30rpx;
background-color: #ffffff;
border-radius: 12rpx;
border-radius: 12rpx;
min-height: 460rpx;
.no-order-image {
......
......@@ -21,7 +21,7 @@
</view>
<view class="video" v-for="key in item.section" @click=details(key.id)>
<view class="video_1" >
<view class="text" v-text="key.ware=='0'?'视频':'图文'">
<view class="text" v-text="wareType(key.ware)">
</view>
<text>1-{{key.order}}</text>
......@@ -56,7 +56,7 @@
methods: {
//获取章节详情
getCapterDetails() {
console.log(1111111)
console.log('获取章节详情')
this.$u.api
.ChapterDetails(this.params)
.then((res) => {
......@@ -105,6 +105,27 @@
uni.navigateTo({
url:"./section?section_id=" + id
})
},
wareType(type){
let res = "";
switch (type) {
case "":
res = "图文";
break;
case "0":
case "0,1":
case "0,1,2":
res = "视频";
break;
case "1":
res = "ppt";
break;
case "2":
case "1,2":
res = "pdf";
break;
}
return res;
}
}
}
......
<template>
<view>
<view class="title">
{{CourseSectionlist.name}}
</view>
<view class="content" v-html="CourseSectionlist.content">
{{CourseSectionlist.content}}
</view>
</view>
<view class="learn-vedio" v-if="isShowVideo">
<view class="uni-padding-wrap uni-common-mt">
<view><video
object-fit="cover"
class="course-video"
id="courseVideo"
:src="courseSrc"
@play="playCourse"
@error="videoErrorCallback"
controls
></video
></view>
<view class="title-content">
<view class="item-content">
<view class="item-st">
<image style="width: 80rpx; height: 36rpx" :src="kcImage"></image>
<text class="item-st-text">{{
courseTitle.split(" ") ? courseTitle.split(" ")[0] : ""
}}</text>
</view>
<view class="item-title">{{
courseTitle.split(" ") ? courseTitle.split(" ")[1] : ""
}}</view>
</view>
<view
>接单操作须知有助你快速了解充电桩安装业务,提高接单效率,请认真查看及学习。</view
>
</view>
<view class="learn-view" v-if="courseId >= 0">
<view class="learn-view-title">视频内容介绍</view>
<!-- <view
class="learn-list"
v-for="(item, key) in courseOutlines[courseId]"
:key="key"
> -->
<view class="learn-list-item">{{ item }}</view>
</view>
</view>
</view>
<view v-else>
<view class="title">
{{CourseSectionlist.name}}
</view>
<view class="content" v-html="CourseSectionlist.content">
{{CourseSectionlist.content}}
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
CourseSectionlist:null,
section_id:{
section_id:0
}
}
},
onLoad(id) {
this.section_id.section_id = id.section_id
this.getCourseSection()
},
methods: {
getCourseSection() {
this.$u.api
.CourseSection(this.section_id)
.then((res) => {
if (res.code == 200) {
if (res.data) {
this.CourseSectionlist = res.data;
console.log("--------")
console.log(this.CourseSectionlist)
if (res.data.length < 5) {
//判断接口返回数据量小于请求数据量,则表示此为最后一页
this.isLoadMore = true;
this.loadStatus = "nomore";
} else {
this.isLoadMore = false;
}
} else {
this.isLoadMore = true;
this.loadStatus = "nomore";
}
} else {
//接口请求失败的处理
uni.showToast({
title: res.message,
icon: "none"
});
this.isLoadMore = false;
if (this.params.start > 0) {
this.page -= 5;
}
}
})
.catch((err) => {
uni.showToast({
title: err,
icon: "none",
});
this.isLoadMore = false;
if (this.params.start > 0) {
this.page -= 5;
}
});
},
let app = getApp();
export default {
data() {
return {
courseId: "",
courseStatus: 0,
courseSrc: "",
courseTitle: "",
courseDesc: "",
currentIndex: -1, // 第几个视频
section_id:0,
isShowVideo: false,
CourseSectionlist: {},//节信息
};
},
computed: {
courseOutlines() {
// 视频内容介绍
return {
1: [
"1、考核规则:接单及时率",
"2、考核规则:上门及时率",
"3、考核规则:安装完工率",
"4、考核规则:资料提交及时率",
"5、考核规则:安装完工率",
"6、考核规则:客户满意度",
],
2: ["1、必备材料4大类", "2、施工工具准备"],
3: [
"1、接线安装工艺标准",
"2、PVC、镀锌管电缆管明敷",
"3、电缆敷设的防火要求",
"4、电源点标识",
"5、配电箱接线及安装",
"6、管线敷设接头处理",
"7、充电桩内部接线",
"8、配电箱安装",
],
4: ["1、勘测环节录单要求", "2、安装环节录单要求"],
};
},
kcImage() {
return process.uniEnv.qn_base_url + "kc.png";
},
},
onLoad(e) {
this.courseSrc = 'https://qn-static.banshouhui.com/self-support/videoen.mp4';
this.courseTitle = '大吉大利';
this.courseDesc = '今晚吃鸡';
this.section_id = e.section_id
this.getCourseSection({section_id:e.section_id})
},
onReady: function (res) {
// #ifndef MP-ALIPAY
this.videoContext = uni.createVideoContext("courseVideo");
// #endif
},
methods: {
videoErrorCallback: function (e) {
uni.showModal({
content: e.target.errMsg,
showCancel: false,
});
},
getRandomColor: function () {
const rgb = [];
for (let i = 0; i < 3; ++i) {
let color = Math.floor(Math.random() * 256).toString(16);
color = color.length == 1 ? "0" + color : color;
rgb.push(color);
}
return "#" + rgb.join("");
},
playCourse: function (e) {
if(this.courseStatus && (this.courseStatus == "1"||this.courseStatus == 1)) {
return
}
this.changeCourseStatus();
},
changeCourseStatus() {
let that = this;
if (that.courseId) {
that.$u.api
.saveCourseRate({
courseId: that.courseId,
})
.then((res) => {
if (res.code !== 200) {
uni.showToast({
icon: "none",
title: "更新课程状态失败",
});
}
});
} else {
uni.showToast({
title: "课程ID为空,请重新选择课程",
});
}
},
getCourseSection(param) {
this.$u.api
.CourseSection(param)
.then((res) => {
if (res.code == 200) {
if (res.data) {
this.CourseSectionlist = res.data;
console.log("--------")
console.log(this.CourseSectionlist)
let wareVal = this.CourseSectionlist.ware;
this.isShowVideo = wareVal == "0";
}
}
})
.catch((err) => {
uni.showToast({
title: err,
icon: "none",
});
this.isLoadMore = false;
if (this.params.start > 0) {
this.page -= 5;
}
});
}
},
};
</script>
<style lang="scss">
.title{
text-align: center;
font-size: 45rpx;
font-weight: 700;
margin: 24rpx;
}
.content{
font-size: 30rpx;
padding: 50rpx;
}
<style lang="scss" scoped>
.learn-vedio {
background-color: #f4f5f7;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
overflow-y:auto;
}
.course-video {
width: 100%;
}
.course-title {
font-size: 36rpx;
font-weight: 700;
padding: 80rpx 60rpx 40rpx 60rpx;
}
.course-desc {
margin-left: 60rpx;
}
.title-content {
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
background-color: #ffffff;
color: #999999;
font-size: 24rpx;
.item-content {
display: flex;
align-items: center;
}
.item-st {
width: 80rpx;
height: 36rpx;
padding-right: 2rpx;
text-align: center;
margin-right: 20rpx;
line-height: 24rpx;
position: relative;
.item-st-text {
color: #ffffff;
position: absolute;
font-size: 16rpx;
left: 20rpx;
top: 8rpx;
line-height: 28rpx;
}
}
.item-title {
color: #333333;
font-size: 44rpx;
font-weight: bold;
}
}
.item-content {
display: flex;
padding-bottom: 30rpx;
}
.item-title {
color: #333333;
font-size: 28rpx;
}
.learn-view {
background-color: #ffffff;
border-radius: 12rpx;
padding: 38rpx 30rpx 30rpx 30rpx;
margin-bottom: 20rpx;
font-size: 32rpx;
color: #333333;
.learn-view-title {
font-size: 32rpx;
font-weight: bold;
margin-bottom: 10rpx;
}
.learn-list {
.learn-list-item {
font-size: 28rpx;
margin-top: 30rpx;
margin-bottom: 30rpx;
color: #333333;
}
.line-view {
background-color: #f4f5f7;
height: 2rpx;
width: 100%;
}
}
}
</style>
......@@ -53,30 +53,40 @@ export default {
}
},
methods: {
// 授权用户信息
// 微信授权用户信息
getUserProfile() {
var that = this
uni.getUserProfile({
desc: '用于授权登录',
success: function (res) {
const userInfo = res.userInfo;
app.globalData.authUserInfo = userInfo
app.globalData.authUserInfo.nickName = app.globalData.authUserInfo.nickName || ''
app.globalData.authUserInfo.avatarUrl = app.globalData.authUserInfo.avatarUrl || ''
uni.showLoading({
title: '授权中..',
mask: true
});
that.authLogin()
},
fail: function (res) {
uni.showModal({
title: '授权失败',
content: '请允许获取用户信息的授权',
showCancel: false
});
}
})
if(uni.getUserProfile) {
// 每次触发 uni.getUserProfile 均会弹出授权窗口,用户授权后可成功获取用户信息
uni.getUserProfile({
desc: '用于授权登录',
success: function (res) {
const userInfo = res.userInfo;
app.globalData.authUserInfo = userInfo
app.globalData.authUserInfo.nickName = app.globalData.authUserInfo.nickName || ''
app.globalData.authUserInfo.avatarUrl = app.globalData.authUserInfo.avatarUrl || ''
uni.showLoading({
title: '授权中..',
mask: true
});
that.authLogin()
},
fail: function (res) {
uni.showModal({
title: '授权失败',
content: '请允许获取用户信息的授权',
showCancel: false
});
}
})
} else {
// 可能由于账号配置,或者其他原因导致无法调起微信用户授权
uni.showModal({
title: '授权失败',
content: '请确认你的用户授权是否可用',
showCancel: false
});
}
},
authLogin() {
var that = this
......
<!-- 过程反馈 -->
<template>
<view class="feedback-box bg">
<u-navbar back-icon-color="#FFFFFF" :background="background" title="过程反馈" title-color="#fff" :border-bottom="false"></u-navbar>
<u-navbar back-icon-color="#FFFFFF" :background="background" title="过程反馈" titleColor="#FFFFFF" :border-bottom="false"></u-navbar>
<view class="content u-p-l-30 u-p-r-30">
<view class="width-320 u-m-t-20">
<!-- <view class="width-320 u-m-t-20">
<u-subsection
:bold="false"
:current="curNow"
:list="list"
:current="curSub"
:list="subList"
active-color="white"
bg-color="white"
height="72"
......@@ -15,29 +15,54 @@
button-color="#2272FF"
border-radius="36"
></u-subsection>
</view> -->
<view class="top-tab">
<u-tabs
:list="tabList"
:current="curTab"
height="80"
gutter="89"
bar-height="4"
bar-width="44"
bg-color="none"
active-color="#FFFFFF"
inactive-color="#FFFFFF"
font-size="32"
@change="changeTab"
></u-tabs>
</view>
<!-- <view class="con-box">
</view> -->
<view class="con-box">
<view class="title">{{feedback.own.title}}</view>
<view class="u-flex u-flex-wrap">
<view :class="{'txt-item':true,'active':true}" v-for="(txt,index) in feedback.own.list" :key="index">
<text class="txt">{{txt}}</text>
<view
v-for="(item, index) in options[curTab]"
:key="index"
@click="changeOwn(index)"
:class="{'txt-item':true,'active': (trace.reasonRelegation == index)}">
<text class="txt">{{index}}</text>
</view>
</view>
</view>
<view class="con-box">
<u-gap height="30"></u-gap>
<view class="title">{{feedback.type.title}}</view>
<view class="u-flex u-flex-wrap">
<view :class="{'txt-item':true,'active':false}" v-for="(txt,index) in feedback.type.list" :key="index">
<view
v-for="(txt, index) in options[curTab][trace.reasonRelegation]"
:key="index"
@click="changeType(txt)"
:class="{'txt-item':true,'active': (trace.reason == txt)}">
<text class="txt">{{txt}}</text>
</view>
</view>
<u-input class="textarea" height="156" type="textarea" placeholder="请补充详细说明,以便于记录您的接单信用分"></u-input>
<u-input v-show="showRemark" v-model="trace.remark" class="textarea" height="156" type="textarea" placeholder="请补充详细说明,以便于记录您的接单信用分"></u-input>
</view>
<appoint-time @dateChange="dateChange" @timeChange="timeChange" @weekChange="weekChange"></appoint-time>
</view>
<view class="u-m-60">
<button class="btn">确定</button>
<button class="btn" @click="submitFrom" :loading="submiting" :disabled="disabledSubmitBtn">确定</button>
</view>
</view>
</template>
......@@ -47,40 +72,139 @@
export default {
data() {
return {
orderId: null,
categoryId: null,
showRemark: false,
submiting: false,
background: {
backgroundColor: 'none',
},
// questionList: ['个人', '客户', '现场/客户'],
tabList: [{name: '报单'}, {name: '改约'}],
curTab: 0,
feedback: {
own:{
title:'问题归属',
list:['个人', '客户', '现场/客户'],
},
type:{
title:'问题类型',
list:['有事耽搁', '未带齐工具', '个人改约','其他']
},
appoint:{
title:'预约时间',
}
},
list:['报备','预约'],
curNow: 1
config: null,
options: [],
trace: {
reasonType: '', // 反馈类型
reasonRelegation: '', // 反馈归属
reason: '', // 反馈原因
appointmentDatetime: null, // 预约时间
appointmentDatetimeRange: '', // 预约时间段类型
nextTraceDatetime: '', // 下次跟踪时间
remark: '', // 备注
},
};
},
components:{
appointTime
},
watch: {
vuex_token(val) {
this.initPageData()
}
},
computed: {
disabledSubmitBtn() {
debugger
let self = this
if(self.trace.reasonType == '预约'
&& (self.trace.appointmentDatetime == null || self.trace.appointmentDatetimeRange == ''
|| self.trace.nextTraceDatetime == '')) {
return true
} else if(self.trace.reasonType != '预约'
&& (!self.trace.reasonType || !self.trace.reasonRelegation || !self.trace.reason)) {
return true
}
return false
},
},
async onLoad(e) {
this.orderId = 1
this.categoryId = 88
if(e) {
this.orderId = e.orderId || null
this.categoryId = e.categoryId || null
}
uni.showLoading({
title: "数据加载中",
mask: true
})
await this.initPageData()
},
methods: {
async initPageData() {
let self = this
let params = {categoryId: self.categoryId}
let res = await self.$u.api.feedbackConfig(params)
if(res && res.code == 200) {
self.config = res.data
self.initParams()
self.buildConfig()
}
uni.hideLoading()
},
buildConfig() {
let self = this
if(self.config) {
let tabs = Object.keys(self.config)
let list = Object.values(self.config)
tabs.forEach(function(tab, index){
self.tabList[index] = {name: tab}
self.options[index] = list[index]
})
}
},
initParams() {
let self = this
if(self.config) {
let tabs = Object.keys(self.config)
let list = Object.values(self.config)
let relegation = Object.keys(list[self.curTab])[0]
let types = Object.values(list[self.curTab][relegation])
self.trace.reasonType = tabs[self.curTab]
self.trace.reasonRelegation = relegation
self.trace.reason = types[0]
if(self.trace.reasonType == '改约') {
self.showRemark = true
} else {
self.showRemark = false
self.trace.remark = ''
}
}
},
/**
* 拒单
* 切换tab项
*/
rejectOrder() {
console.log("点击拒单")
changeTab(index) {
this.curTab = index;
this.initParams()
},
changeOwn(key) {
let self = this
self.trace.reasonRelegation = key
self.trace.reason = self.options[self.curTab][key][0]
},
sectionChange(index) {
this.curNow = index;
changeType(key) {
this.trace.reason = key
},
/**
* 拒单
*/
// rejectOrder() {
// console.log("点击拒单")
// },
weekChange(data){
// 点击下一周
console.log(data,'week-data')
......@@ -93,6 +217,21 @@
// 时间段选择变化
console.log(data,'week-data')
},
async submitFrom() {
let self = this
self.orderId = 666
if(!self.orderId) {
uni.showToast({
icon:error,
title:"工单ID不能为空"
})
return false
}
self.submiting = true
let res = await self.$u.api.traceAndAppointment(self.trace, self.orderId)
self.submiting = false
},
}
}
</script>
......@@ -107,12 +246,28 @@
background-size: 750rpx 600rpx;
background-repeat: no-repeat;
}
.feedback-box {
.header {
padding: 12rpx 30rpx 40rpx 30rpx;
display: flex;
justify-content: space-between;
align-items: center;
.title {
font-size: 40rpx;
font-weight: bold;
color: #FFFFFF;
}
}
}
/deep/ .u-subsection{
padding:4rpx!important;
}
.top-tab{
text-align: center;
}
.con-box{
margin-top:30rpx;
padding:30rpx 30rpx 30rpx 20rpx;
padding: 30rpx 30rpx 28rpx 30rpx;
border-radius: 12rpx;
background-color: #FFFFFF;
.title{
......@@ -170,6 +325,19 @@
height:0;
}
}
.btn{
padding:30rpx;
border-radius: 52rpx;
line-height: 44rpx;
font-size:32rpx;
text-align: center;
background-color: #2272FF;
color:#fff;
&::after{
content:'';
height:0;
}
}
.width-320{
width:320rpx;
}
......
<template>
<view>
<view class="wrap">
<view class="tools-box">
<view class="search-sub">
<u-subsection
:current="curNow"
:list="['待受理', '已完工']"
active-color="white"
bg-color="white"
inactive-color="#666"
button-color="#2272FF"
border-radius="36"
@change="sectionChange"
></u-subsection>
</view>
<view class="search-btn">
<u-icon name="search" color="#666" size="32"></u-icon>
<text class="search-btn-text">搜订单</text>
</view>
</view>
<view class="u-tabs-box" v-show="showSview">
<u-tabs-swiper
activeColor="#2272FF"
bg-color="none"
inactive-color="#999"
bar-height="4" bar-width="44"
:offset="[-1,10]"
ref="tabs"
:list="list"
:current="current"
@change="change"
:is-scroll="false"
swiperWidth="750"
></u-tabs-swiper>
</view>
<swiper v-show="showSview" class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
<swiper-item class="swiper-item">
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
<view class="page-box">
<view class="order" v-for="(res, index) in orderList" :key="res.id">
<view class="top">
<view class="left">
<view class="tag">{{ res.orderServiceType }}</view>
<view class="store">{{ res.categoryName }}</view>
<view >{{ res.orderNumber }}</view>
</view>
<view class="right">{{ res.orderBusinessTypeText }}</view>
</view>
<view class="content">
<view class="title u-line-2">
<text>{{res.contactName }}</text> <text style="margin-left: 8rpx;">{{ res.contactPhone }}</text>
</view>
</view>
<view class="address u-line-2">
<view class="left">
<view ><u-icon name="map" size="32"></u-icon>
<text style="margin-left: 8rpx;">{{res.contactAddress }}</text></view>
</view>
<view class="right">{{getDistance(res.contactAddressLatitud,res.contactAddressLongitud)}}km</view>
</view>
<u-divider margin-top="16" half-width="630" border-color="#F4F5F7" :use-slot="false">
</u-divider>
<view class="bottom">
<view class="left">
<view class="tag">{{res.currentOverTime * 1000 > new Date().getTime()?'剩':'超'}}</view>
<u-count-down :timestamp="timestampDiff(res.currentOverTime)" font-size="44" color="#FF930D" :ref="'uCountDown' + index" @change="timeChange(res.currentOverTime,index)" >
</u-count-down>
</view>
<view class="right-btn" @click="viewOderItem(index)">
<text>去预约</text>
</view>
</view>
</view>
<u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore>
</view>
</scroll-view>
</swiper-item>
<swiper-item class="swiper-item">
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
<view class="page-box">
<view class="order" v-for="(res, index) in orderList" :key="res.id">
<view class="top">
<view class="left">
<view class="tag">{{ res.orderServiceType }}</view>
<view class="store">{{ res.categoryName }}</view>
<view >{{ res.orderNumber }}</view>
</view>
<view class="right">{{ res.orderBusinessTypeText }}</view>
</view>
<view class="content">
<view class="title u-line-2">
<text>{{res.contactName }}</text> <text style="margin-left: 8rpx;">{{ res.contactPhone }}</text>
</view>
</view>
<view class="address u-line-2">
<view class="left">
<view ><u-icon name="map" size="32"></u-icon>
<text style="margin-left: 8rpx;">{{res.contactAddress }}</text></view>
</view>
<view class="right">{{getDistance(res.contactAddressLatitud,res.contactAddressLongitud)}}km</view>
</view>
<u-divider margin-top="16" half-width="630" border-color="#F4F5F7" :use-slot="false">
</u-divider>
<view class="bottom">
<view class="left">
<view class="tag">{{res.currentOverTime * 1000 > new Date().getTime()?'剩':'超'}}</view>
<u-count-down :timestamp="timestampDiff(res.currentOverTime)" font-size="44" color="#FF930D" :ref="'uCountDown' + index" @change="timeChange(res.currentOverTime,index)" >
</u-count-down>
</view>
<view class="right-btn" @click="viewOderItem(index)">
<text>去签到</text>
</view>
</view>
</view>
<u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore>
</view>
</scroll-view>
</swiper-item>
<swiper-item class="swiper-item">
<scroll-view scroll-y style="height: 100%;width: 100%;" v-if="orderList.length === 0">
<view class="page-box">
<view>
<view class="centre">
<image src="https://cdn.uviewui.com/uview/template/taobao-order.png" mode=""></image>
<view class="explain">
您还没有相关的订单
<view class="tips">可以去看看有那些想买的</view>
</view>
<view class="btn">随便逛逛</view>
</view>
</view>
</view>
</scroll-view>
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom" v-else>
<view class="page-box">
<view class="order" v-for="(res, index) in orderList" :key="res.id">
<view class="top">
<view class="left">
<view class="tag">{{ res.orderServiceType }}</view>
<view class="store">{{ res.categoryName }}</view>
<view >{{ res.orderNumber }}</view>
</view>
<view class="right">{{ res.orderBusinessTypeText }}</view>
</view>
<view class="content">
<view class="title u-line-2">
<text>{{res.contactName }}</text> <text style="margin-left: 8rpx;">{{ res.contactPhone }}</text>
</view>
</view>
<view class="address u-line-2">
<view class="left">
<view ><u-icon name="map" size="32"></u-icon>
<text style="margin-left: 8rpx;">{{res.contactAddress }}</text></view>
</view>
<view class="right">{{getDistance(res.contactAddressLatitud,res.contactAddressLongitud)}}km</view>
</view>
<u-divider margin-top="16" half-width="630" border-color="#F4F5F7" :use-slot="false">
</u-divider>
<view class="bottom">
<view class="left">
<view class="tag">{{res.currentOverTime * 1000 > new Date().getTime()?'剩':'超'}}</view>
<u-count-down :timestamp="timestampDiff(res.currentOverTime)" font-size="44" color="#FF930D" :ref="'uCountDown' + index" @change="timeChange(res.currentOverTime,index)" >
</u-count-down>
</view>
<view class="right-btn" @click="viewOderItem(index)">
<text>去完工</text>
</view>
</view>
</view>
<u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore>
</view>
</scroll-view>
</swiper-item>
<swiper-item class="swiper-item">
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
<view class="page-box">
<view class="order" v-for="(res, index) in orderList" :key="res.id">
<view class="top">
<view class="left">
<view class="tag">{{ res.orderServiceType }}</view>
<view class="store">{{ res.categoryName }}</view>
<view >{{ res.orderNumber }}</view>
</view>
<view class="right">{{ res.orderBusinessTypeText }}</view>
</view>
<view class="content">
<view class="title u-line-2">
<text>{{res.contactName }}</text> <text style="margin-left: 8rpx;">{{ res.contactPhone }}</text>
</view>
</view>
<view class="address u-line-2">
<view class="left">
<view ><u-icon name="map" size="32"></u-icon>
<text style="margin-left: 8rpx;">{{res.contactAddress }}</text></view>
</view>
<view class="right">{{getDistance(res.contactAddressLatitud,res.contactAddressLongitud)}}km</view>
</view>
<u-divider margin-top="16" half-width="630" border-color="#F4F5F7" :use-slot="false">
</u-divider>
<view class="bottom">
<view class="left">
<view class="tag">{{res.currentOverTime * 1000 > new Date().getTime()?'剩':'超'}}</view>
<u-count-down :timestamp="timestampDiff(res.currentOverTime)" font-size="44" color="#FF930D" :ref="'uCountDown' + index" @change="timeChange(res.currentOverTime,index)" >
</u-count-down>
</view>
<view class="right-btn" @click="viewOderItem(index)">
<text>审核中</text>
</view>
</view>
</view>
<u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore>
</view>
</scroll-view>
</swiper-item>
<swiper-item class="swiper-item">
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
<view class="page-box">
<view class="order" v-for="(res, index) in orderList" :key="res.id">
<view class="top">
<view class="left">
<view class="tag">{{ res.orderServiceType }}</view>
<view class="store">{{ res.categoryName }}</view>
<view >{{ res.orderNumber }}</view>
</view>
<view class="right">{{ res.orderBusinessTypeText }}</view>
</view>
<view class="content">
<view class="title u-line-2">
<text>{{res.contactName }}</text> <text style="margin-left: 8rpx;">{{ res.contactPhone }}</text>
</view>
</view>
<view class="address u-line-2">
<view class="left">
<view ><u-icon name="map" size="32"></u-icon>
<text style="margin-left: 8rpx;">{{res.contactAddress }}</text></view>
</view>
<view class="right">{{getDistance(res.contactAddressLatitud,res.contactAddressLongitud)}}km</view>
</view>
<u-divider margin-top="16" half-width="630" border-color="#F4F5F7" :use-slot="false">
</u-divider>
<view class="bottom">
<view class="left">
<view class="tag">{{res.currentOverTime * 1000 > new Date().getTime()?'剩':'超'}}</view>
<u-count-down :timestamp="timestampDiff(res.currentOverTime)" font-size="44" color="#FF930D" :ref="'uCountDown' + index" @change="timeChange(res.currentOverTime,index)" >
</u-count-down>
</view>
<view class="right-btn" @click="viewOderItem(index)">
<text>去处理</text>
</view>
</view>
</view>
<u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore>
</view>
</scroll-view>
</swiper-item>
</swiper>
<swiper v-show="!showSview" class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
<swiper-item class="swiper-item">
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
<view class="page-box">
<view class="order" v-for="(res, index) in orderList" :key="res.id">
<view class="top">
<view class="left">
<view class="tag">{{ res.orderServiceType }}</view>
<view class="store">{{ res.categoryName }}</view>
<view >{{ res.orderNumber }}</view>
</view>
<view class="right">{{ res.orderBusinessTypeText }}</view>
</view>
<view class="content">
<view class="title u-line-2">
<text>{{res.contactName }}</text> <text style="margin-left: 8rpx;">{{ res.contactPhone }}</text>
</view>
</view>
<view class="address u-line-2">
<view class="left">
<view >
<u-icon name="map" size="32"></u-icon>
<text style="margin-left: 8rpx;">{{res.contactAddress }}</text>
<text style="margin-left: 200rpx; font-size:large;" @click="viewOderItem(index)" > > </text>
</view>
</view>
</view>
<u-divider margin-top="16" half-width="630" border-color="#F4F5F7" :use-slot="false">
</u-divider>
<view class="bottom">
<view class="left">
<text>审核时间 :</text><text>{{res.auditDatetime}}</text>
</view>
<view >
<text>已完工</text>
</view>
</view>
</view>
<!-- <u-loadmore :status="loadStatus[0]" bgColor="#f2f2f2"></u-loadmore> -->
</view>
</scroll-view>
</swiper-item>
</swiper>
</view>
</view>
</template>
<script>
export default {
data() {
return {
showSview : true,
curNow : 0,
timestamp:1000,
//waitAccept、waitAppointment、waitCheckIn、waitFinish、exception、finish
indexStatus:{0:'waitAccept',1:'waitAppointment',2:'waitCheckIn',3:'waitFinish',4:'exception',5:'finish'},
orderList: [],
dataList: [
{
id: 1,
store: '夏日流星限定贩卖',
deal: '交易成功',
goodsList: [
{
goodsUrl: '//img13.360buyimg.com/n7/jfs/t1/103005/7/17719/314825/5e8c19faEb7eed50d/5b81ae4b2f7f3bb7.jpg',
title: '【冬日限定】现货 原创jk制服女2020冬装新款小清新宽松软糯毛衣外套女开衫短款百搭日系甜美风',
type: '灰色;M',
deliveryTime: '付款后30天内发货',
price: '348.58',
number: 2
<template>
<TabBarPage title="订单" :fixed="true">
<!-- <view class="wrap"> -->
<view class="tools-box">
<view class="search-sub">
<u-subsection :current="curNow" :list="subList" active-color="white" bg-color="white"
inactive-color="#666" button-color="#2272FF" border-radius="36" @change="sectionChange">
</u-subsection>
</view>
<view class="search-btn">
<u-icon name="search" color="#666" size="32"></u-icon>
<text class="search-btn-text">搜订单</text>
</view>
</view>
<view class="u-tabs-box" v-show="curNow == 0">
<u-tabs-swiper activeColor="#2272FF" bg-color="none" inactive-color="#999" bar-height="4" bar-width="44"
:offset="[-1,10]" ref="tabs" :list="list" count="total" :current="current" @change="change"
:is-scroll="false" swiperWidth="750"></u-tabs-swiper>
</view>
<swiper class="swiper-box" :current="swiperCurrent" @transition="transition"
@animationfinish="animationfinish">
<swiper-item class="swiper-item" v-for="(res, ind) in orderList" :key="ind">
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom" scroll-anchoring>
<view class="page-box">
<view v-for="(item, index) in res" :key="item.orderId">
<OrderCell :orderData="item" :orderType="orderType" :location="dataValue"
@click="handleClick(item)" @action="handleAction(item)"> </OrderCell>
</view>
<u-loadmore :status="loadStatus[ind]" bgColor="#F4F5F7"></u-loadmore>
</view>
</scroll-view>
</swiper-item>
</swiper>
<!-- </view> -->
</TabBarPage>
</template>
<script>
import TabBarPage from "@/components/tabBarList/index.vue"
import OrderCell from "@/components/order/index.vue";
export default {
components: {
TabBarPage,
OrderCell
},
data() {
return {
showSview: true,
curNow: 0,
timestamp: 1000,
triggered: false,
pageNumber: 0,
pageSize: 10,
//waitAccept、waitAppointment、waitCheckIn、waitFinish、exception、finish
indexStatus: {
0: 'waitAccept',
1: 'waitAppointment',
2: 'waitCheckIn',
3: 'waitFinish',
4: 'exception',
5: 'finish'
},
orderList: [[],[],[],[],[],[]],
dataList: [],
list: [{
name: '待预约',
total: 0,
},
{
name: '待签到',
total: 0,
},
{
name: '待完工',
total: 0,
},
{
name: '待审核',
total: 0,
},
{
name: '异常单',
total: 0,
}
],
current: 0,
swiperCurrent: 0,
tabsHeight: 0,
dx: 0,
loadStatus: ['loading','loading','loading','loading','loading','loading'],
dataValue: [],
total: 0
};
},
onLoad() {
this.getLocation();
this.getOrderCount();
this.getOrderList(0);
},
computed: {
subList() {
return ['待受理', '已完工']
},
// 0:待接单 1:'去预约', 2:'去签到', 3:'去完工', 4:'审核中', 5:'去处理', 6'已完工'
orderType() {
return this.currentIndex + 1
},
currentIndex() {
return this.curNow == 0 ? this.swiperCurrent : 5
}
},
methods: {
sectionChange(index) {
this.curNow = index;
this.pageNumber = 0
if (index === 1) {
this.showSview = false
// 加载已完工的数据
this.getOrderList(5)
} else {
this.showSview = true
// 加载已完工的数据
this.getOrderList(0)
}
},
/**
* 获取当前位置的经纬度
*/
getLocation() {
let self = this
const dataValue = this.dataValue || []
const waterInfo = this.waterInfo
uni.getLocation({
type: 'gcj02',
success: function(res) {
dataValue.push(res.longitude)
dataValue.push(res.latitude)
self.dataValue = dataValue
},
fail(err) {
}
});
},
reachBottom(e) {
console.log(e)
console.log(this.loadStatus[this.currentIndex])
if (this.loadStatus[this.currentIndex] != 'loadmore') return
this.loadStatus[this.currentIndex] == 'loading'
this.getOrderList(this.currentIndex)
},
// 页面数据
getOrderList(index) {
// 状态处理
this.pageNumber += 1
var param = {
pageNumber: this.pageNumber,
pageSize: this.pageSize,
keyword: '',
type: this.indexStatus[index]
}
var self = this;
self.$u.api.listOrder(param).then((res) => {
if (res.code == 200) {
console.log("getOrderList", res.data)
/*↓↓↓↓↓↓↓↓↓↓测试数据↓↓↓↓↓↓↓↓↓↓*/
var res = {
data: {
total: 15,
orderType: this.currentIndex,
list: [{
orderServiceType: '安装', // 服务类型:安装、维修
categoryName: '充电桩', // 品类:充电桩
orderBusinessTypeText: '分配单', // 业务类型:分配单、订单池
orderNumber: 'OR2021041809827', // 工单编号
contactName: '郭小清', // 客户信息
contactPhone: '13631612077', // 联系方式
contactAddress: '湾街道荔枝花园D座125号', // 详细地址
contactAddressLatitud: '116.3896', // 联系人地址经度
contactAddressLongitud: '39.91917', // 联系人地址纬度
orderStatus: 0, // 工单状态
appointmentDatetime: '', // 预约时间
currentWillOverTime: 10000, // 剩余时间
currentOverTime: 0, // 超过时间
auditDatetime: '2021.04.19 12:45:09', // 审核时间
submissionTime: '2021.04.19 16:24:48', // 提交时间
auditResults: {}, // 审核结果
orderBusinessType: 'R', // 业务类型 R 为抢单
}]
}
}
]
},
{
id: 2,
store: '江南皮革厂',
deal: '交易失败',
goodsList: [
{
goodsUrl: '//img14.360buyimg.com/n7/jfs/t1/60319/15/6105/406802/5d43f68aE9f00db8c/0affb7ac46c345e2.jpg',
title: '【冬日限定】现货 原创jk制服女2020冬装新款小清新宽松软糯毛衣外套女开衫短款百搭日系甜美风',
type: '粉色;M',
deliveryTime: '付款后7天内发货',
price: '128.05',
number: 1
}
]
},
{
id: 3,
store: '三星旗舰店',
deal: '交易失败',
goodsList: [
{
goodsUrl: '//img11.360buyimg.com/n7/jfs/t1/94448/29/2734/524808/5dd4cc16E990dfb6b/59c256f85a8c3757.jpg',
title: '三星(SAMSUNG)京品家电 UA65RUF70AJXXZ 65英寸4K超高清 HDR 京东微联 智能语音 教育资源液晶电视机',
type: '4K,广色域',
deliveryTime: '保质5年',
price: '1998',
number: 3
}
]
},
{
id: 4,
store: '三星旗舰店',
deal: '交易失败',
goodsList: [
{
goodsUrl: '//img10.360buyimg.com/n7/jfs/t22300/31/1505958241/171936/9e201a89/5b2b12ffNe6dbb594.jpg!q90.jpg',
title: '法国进口红酒 拉菲(LAFITE)传奇波尔多干红葡萄酒750ml*6整箱装',
type: '4K,广色域',
deliveryTime: '珍藏10年好酒',
price: '1543',
number: 3
}
]
},
{
id: 5,
store: '三星旗舰店',
deal: '交易成功',
goodsList: [
{
goodsUrl: '//img12.360buyimg.com/n7/jfs/t1/52408/35/3554/78293/5d12e9cfEfd118ba1/ba5995e62cbd747f.jpg!q90.jpg',
title: '企业微信 中控人脸指纹识别考勤机刷脸机 无线签到异地多店打卡机WX108',
type: '识别效率高',
deliveryTime: '使用方便',
price: '451',
number: 9
}
]
}
],
list: [
{
name: '待预约',
count: 3
},
{
name: '待签到',
count: 2
},
{
name: '待完工',
count: 2
},
{
name: '待审核',
count: 10
},
{
name: '异常单',
count: 2
}
],
current: 0,
swiperCurrent: 0,
tabsHeight: 0,
dx: 0,
loadStatus: ['loadmore', 'loadmore', 'loadmore', 'loadmore'],
dataValue:[],
total:0
};
},
onLoad() {
this.getLocation();
this.getOrderCount();
this.getOrderList(0);
},
computed: {
// 价格小数
priceDecimal() {
return val => {
if (val !== parseInt(val)) return val.slice(-2);
else return '00';
};
},
// 价格整数
priceInt() {
return val => {
if (val !== parseInt(val)) return val.split('.')[0];
else return val;
};
}
},
methods: {
sectionChange(index){
if(index === 1){
this.showSview = false
// 加载已完工的数据
this.getOrderList(5)
}else {
this.showSview = true
// 加载已完工的数据
this.getOrderList(0)
}
this.curNow = index;
},
timeChange(currentOverTime,index){
let self = this
var nowTime = new Date(); // 当前时间
if(nowTime.getTime() > currentOverTime*1000){
self.$refs['uCountDown'+index][0].seconds += 2
}
},
timestampDiff(currentOverTime){
var nowTime = new Date(); // 当前时间
if(nowTime.getTime() > currentOverTime*1000){
var diff = nowTime.getTime() - (currentOverTime*1000);
}else{
var diff = (currentOverTime*1000) - nowTime.getTime();
}
return diff;
},
/**
* 获取当前位置的经纬度
*/
getLocation() {
let self = this
const dataValue = this.dataValue || []
const waterInfo = this.waterInfo
uni.getLocation({
type: 'gcj02',
success: function(res) {
dataValue.push(res.longitude)
dataValue.push(res.latitude)
self.dataValue = dataValue
},
fail(err) {
}
});
},
getDistance(Latitud, Longitud){
return this.distance(Latitud,Longitud,this.dataValue[0],this.dataValue[1])
},
/**
* echo distance(116.3896,39.91917,116.3940,39.91726);
* 计算两点之间直线距离
* @param float $lon1 经度
* @param float $lat1 维度
* @param float $lon2 经度
* @param float $lat2 维度
* @return float 浮点数
*/
distance(la1, lo1, la2, lo2) {
var La1 = la1 * Math.PI / 180.0;
var La2 = la2 * Math.PI / 180.0;
var La3 = La1 - La2;
var Lb3 = lo1 * Math.PI / 180.0 - lo2 * Math.PI / 180.0;
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(La3 / 2), 2),Math.cos(La1) * Math.cos(La2) * Math.pow(Math.sin(Lb3 / 2), 2)));
s = s * 6378.137;//地球半径
s = Math.round(s * 10000) / 10000;
// console.log("计算结果",s,'KM');
return s?s.toFixed(2):0;
},
reachBottom() {
// 此tab为空数据
if (this.current != 2) {
this.loadStatus.splice(this.current, 1, 'loading');
setTimeout(() => {
this.getOrderList(this.current);
}, 1200);
}
},
// 页面数据
getOrderList(index) {
// 状态处理
console.log("chage:",this.indexStatus[index])
var page=0
var pageSize=10
var param = {pageNumber:page,pageSize:pageSize,keyword:'',type:this.indexStatus[index]}
var self = this;
self.$u.api.listOrder(param).then((res) => {
if (res.code == 200) {
console.log("getOrderList",res.data)
if (res.data) {
self.orderList = res.data.list;
// //测试使用
// self.orderList.forEach((item,index)=>{
// if(index === 1){
// item.currentOverTime -= 10
// }
// })
self.total =res.data.total;
}
} else {
console.log(res.message, "获取订单数量失败!");
}
});
},
// 获取订单数量
getOrderCount() {
var self = this; // 加载订单列表
self.$u.api.listOrderCount().then((res) => {
if (res.code == 200) {
console.log("===",res.data)
if (res.data) {
self.list.forEach(item=>{
if(item.name==='待预约'){
item.count=res.data.toAppointmentCount
}else if(item.name==='待签到'){
item.count=res.data.toCheckinCount
}else if(item.name==='待完工'){
item.count=res.data.toFinishCount
}else if(item.name==='待审核'){
item.count=res.data.reviewingCount
}else if(item.name==='异常单'){
item.count=res.data.exceptionCount
}
})
}
} else {
console.log(res.message, "获取订单数量失败!");
}
});
},
// 总价
totalPrice(item) {
let price = 0;
item.map(val => {
price += parseFloat(val.price);
});
return price.toFixed(2);
},
// 总件数
totalNum(item) {
let num = 0;
item.map(val => {
num += val.number;
});
return num;
},
// tab栏切换
change(index) {
this.swiperCurrent = index;
this.getOrderList(index);
},
transition({ detail: { dx } }) {
this.$refs.tabs.setDx(dx);
},
animationfinish({ detail: { current } }) {
this.$refs.tabs.setFinishCurrent(current);
this.swiperCurrent = current;
this.current = current;
},viewOderItem(index) { // 跳转工单详情页面
let order = this.orderList[index]
console.log("order",order)
uni.navigateTo({
url: 'pages/order/detail?id='+order.orderId
})
}
}
};
</script>
<style>
/* #ifndef H5 */
page {
height: 100%;
background-color: #f2f2f2;
}
/* #endif */
</style>
<style lang="scss" scoped>
.order {
width: 710rpx;
background-color: #ffffff;
margin: 20rpx auto;
border-radius: 20rpx;
box-sizing: border-box;
padding: 20rpx;
font-size: 28rpx;
.top {
display: flex;
justify-content: space-between;
align-items: center;
.left {
display: flex;
align-items: center;
.tag {
text-align: center;
width: 84rpx;
height: 40rpx;
background: linear-gradient(270deg, #47ABFF 0%, #2272FF 100%);
border-radius: 8rpx;
font-size: 22rpx;
font-weight: 500;
color: #FFFFFF;
line-height: 40rpx;
}
.store {
margin: 0 10rpx;
font-size: 36rpx;
font-weight: bold;
color: #333333;
line-height: 36px;
}
}
.right {
height: 40rpx;
background: #F4F5F7;
border-radius: 22rpx;
padding: 8rpx 16rpx 8rpx 16rpx;
font-size: 22rpx;
line-height: 24rpx;
font-weight: 400;
color: #333333;
}
}
.item {
display: flex;
flex-direction: column;
margin: 20rpx 0 0;
.content {
.title {
font-size: 26rpx;
font-weight: 400;
color: #333333;
line-height: 52rpx;
}
}
.address {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 24rpx;
font-weight: 400;
color: #333333;
line-height: 52rpx;
.left {
}
.right {
}
}
}
.total {
margin-top: 20rpx;
text-align: right;
font-size: 24rpx;
.total-price {
font-size: 32rpx;
}
}
.bottom {
display: flex;
margin-top: 30rpx;
padding: 0 10rpx;
justify-content: space-between;
align-items: center;
.left {
display: flex;
align-items: center;
justify-content: space-between;
.tag {
text-align: center;
width: 54rpx;
height: 54rpx;
background: #FF930D;
font-size: 26rpx;
font-weight: 500;
color: #FFFFFF;
line-height: 54rpx;
border-radius: 50%;
margin-right: 20rpx;
}
}
.right-btn {
text-align: center;
width: 200rpx;
height: 80rpx;
background: #2272FF;
border-radius: 40rpx;
font-size: 32rpx;
font-weight: 600;
color: #FFFFFF;
line-height: 80rpx;
font-family: PingFangSC-Semibold, PingFang SC;
}
}
}
.centre {
text-align: center;
margin: 200rpx auto;
font-size: 32rpx;
image {
width: 164rpx;
height: 164rpx;
border-radius: 50%;
margin-bottom: 20rpx;
}
.tips {
font-size: 24rpx;
color: #999999;
margin-top: 20rpx;
}
.btn {
margin: 80rpx auto;
width: 200rpx;
border-radius: 32rpx;
line-height: 64rpx;
color: #ffffff;
font-size: 26rpx;
background: linear-gradient(270deg, rgba(249, 116, 90, 1) 0%, rgba(255, 158, 1, 1) 100%);
}
}
.wrap {
display: flex;
flex-direction: column;
height: calc(100vh - var(--window-top));
width: 100%;
}
.swiper-box {
flex: 1;
}
.swiper-item {
height: 100%;
}
.tools-box {
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 20rpx 30rpx 18rpx 34rpx;
.search-sub {
height: 72rpx;
width: 320rpx;
}
.search-btn {
height: 72rpx;
width: 220rpx;
background-color: #ffffff;
border-radius: 36rpx;
color: #666666;
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
.search-btn-text {
line-height: 36rpx;
font-weight: 400;
font-size: 26rpx;
}
}
}
.order-taps {
height: 80rpx;
padding: 8rpx 30rpx 20rpx 30rpx;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
.order-taps-item {
font-size: 28rpx;
font-weight: 400;
color: #999999;
line-height: 20px;
.taps-count {
position: absolute;
font-size: 16rpx;
font-weight: 400;
line-height: 16rpx;
width: 36rpx;
height: 24rpx;
background: #FFFFFF;
border-radius: 16rpx;
border: 2rpx solid #FA5A49;
text-align: center;
color: #FA5A49;
}
}
}
res.data.list = [...res.data.list, ...res.data.list, ...res.data.list, ...res.data.list,
...res.data.list,...res.data.list,...res.data.list,...res.data.list,...res.data.list,...res.data.list]
/*↑↑↑↑↑↑↑↑↑↑测试数据↑↑↑↑↑↑↑↑↑↑↑↑↑*/
// 后台需要返回order_type,防止数据返回延迟期间点击了其他的tab
if (res.data) {
self.orderList[res.data.orderType].push(...res.data.list)
self.list[res.data.orderType].total = res.data.total
self.loadStatus[res.data.orderType] = res.data.total > self.orderList[res.data.orderType].length ? 'loadmore' : 'nomore'
}
} else {
console.log(res.message, "获取订单数量失败!");
}
});
},
// 获取订单数量
getOrderCount() {
var self = this; // 加载订单列表
self.$u.api.listOrderCount().then((res) => {
if (res.code == 200) {
console.log("===", res.data)
if (res.data) {
self.list.forEach(item => {
if (item.name === '待预约') {
item.count = res.data.toAppointmentCount
} else if (item.name === '待签到') {
item.count = res.data.toCheckinCount
} else if (item.name === '待完工') {
item.count = res.data.toFinishCount
} else if (item.name === '待审核') {
item.count = res.data.reviewingCount
} else if (item.name === '异常单') {
item.count = res.data.exceptionCount
}
})
}
} else {
console.log(res.message, "获取订单数量失败!");
}
});
},
// tab栏切换
change(index) {
this.swiperCurrent = index;
this.getOrderList(index);
},
transition({
detail: {
dx
}
}) {
this.$refs.tabs.setDx(dx);
},
animationfinish({
detail: {
current
}
}) {
this.$refs.tabs.setFinishCurrent(current);
this.swiperCurrent = current;
this.current = current;
},
viewOderItem(orderId) { // 跳转工单详情页面
uni.navigateTo({
url: 'pages/order/detail?id=' + orderId
})
},
handleClick(item) {
console.log('click cell')
this.viewOderItem(item.orderId)
},
handleAction(item) {
console.log('click button')
this.viewOderItem(item.orderId)
}
}
};
</script>
<style>
/* #ifndef H5 */
page {
height: 100%;
background-color: #f2f2f2;
}
/* #endif */
</style>
<style lang="scss" scoped>
.u-tabs-box {
margin-bottom: 30rpx;
}
.order {
// width: 710rpx;
// background-color: #ffffff;
// margin: 20rpx auto;
// border-radius: 20rpx;
// box-sizing: border-box;
// padding: 20rpx;
// font-size: 28rpx;
.top {
display: flex;
justify-content: space-between;
align-items: center;
.left {
display: flex;
align-items: center;
.tag {
text-align: center;
width: 84rpx;
height: 40rpx;
background: linear-gradient(270deg, #47ABFF 0%, #2272FF 100%);
border-radius: 8rpx;
font-size: 22rpx;
font-weight: 500;
color: #FFFFFF;
line-height: 40rpx;
}
.store {
margin: 0 10rpx;
font-size: 36rpx;
font-weight: bold;
color: #333333;
line-height: 36px;
}
}
.right {
height: 40rpx;
background: #F4F5F7;
border-radius: 22rpx;
padding: 8rpx 16rpx 8rpx 16rpx;
font-size: 22rpx;
line-height: 24rpx;
font-weight: 400;
color: #333333;
}
}
.item {
display: flex;
flex-direction: column;
margin: 20rpx 0 0;
.content {
.title {
font-size: 26rpx;
font-weight: 400;
color: #333333;
line-height: 52rpx;
}
}
.address {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 24rpx;
font-weight: 400;
color: #333333;
line-height: 52rpx;
.left {}
.right {}
}
}
.total {
margin-top: 20rpx;
text-align: right;
font-size: 24rpx;
.total-price {
font-size: 32rpx;
}
}
.bottom {
display: flex;
margin-top: 30rpx;
padding: 0 10rpx;
justify-content: space-between;
align-items: center;
.left {
display: flex;
align-items: center;
justify-content: space-between;
.tag {
text-align: center;
width: 54rpx;
height: 54rpx;
background: #FF930D;
font-size: 26rpx;
font-weight: 500;
color: #FFFFFF;
line-height: 54rpx;
border-radius: 50%;
margin-right: 20rpx;
}
}
.right-btn {
text-align: center;
width: 200rpx;
height: 80rpx;
background: #2272FF;
border-radius: 40rpx;
font-size: 32rpx;
font-weight: 600;
color: #FFFFFF;
line-height: 80rpx;
font-family: PingFangSC-Semibold, PingFang SC;
}
}
}
.centre {
text-align: center;
margin: 200rpx auto;
font-size: 32rpx;
image {
width: 164rpx;
height: 164rpx;
border-radius: 50%;
margin-bottom: 20rpx;
}
.tips {
font-size: 24rpx;
color: #999999;
margin-top: 20rpx;
}
.btn {
margin: 80rpx auto;
width: 200rpx;
border-radius: 32rpx;
line-height: 64rpx;
color: #ffffff;
font-size: 26rpx;
background: linear-gradient(270deg, rgba(249, 116, 90, 1) 0%, rgba(255, 158, 1, 1) 100%);
}
}
.wrap {
display: flex;
flex-direction: column;
height: calc(100vh - var(--window-top));
width: 100%;
}
.swiper-box {
flex: 1;
}
.swiper-item {
height: 100%;
.page-box {
padding-bottom: 20rpx;
}
}
.tools-box {
display: flex;
flex-direction: row;
justify-content: space-between;
padding: 20rpx 0rpx 18rpx 0rpx;
.search-sub {
height: 72rpx;
width: 320rpx;
}
.search-btn {
height: 72rpx;
width: 220rpx;
background-color: #ffffff;
border-radius: 36rpx;
color: #666666;
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
.search-btn-text {
line-height: 36rpx;
font-weight: 400;
font-size: 26rpx;
}
}
}
.order-taps {
height: 80rpx;
padding: 8rpx 30rpx 20rpx 30rpx;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
.order-taps-item {
font-size: 28rpx;
font-weight: 400;
color: #999999;
line-height: 20px;
.taps-count {
position: absolute;
font-size: 16rpx;
font-weight: 400;
line-height: 16rpx;
width: 36rpx;
height: 24rpx;
background: #FFFFFF;
border-radius: 16rpx;
border: 2rpx solid #FA5A49;
text-align: center;
color: #FA5A49;
}
}
}
</style>
<template>
<view class="backView">
<view class="ph-pr-arr" v-for="(dataItem, index) in list" :key="index">
<template v-if="dataItem.data.length > 0">
<view class="topTitle"><text>{{ dataItem.title }}</text></view>
<view class="ph-pr-content">
<view v-for="(item,ikey) in dataItem.data"
:class="param[dataItem.type] === item.id ? 'select-item-view' : 'item-view'"
@click="itemClick(dataItem.type, item, ikey)" :key="item.id">
<text class="itemTitle">{{item.name}}</text>
</view>
</view>
</template>
</view>
<u-button class="ph-pr-button" type="primary" shape="circle" @click="handleClick"
:hover-class="selectedAll ? '' : 'none'" :custom-style="buttonStyle">下一步</u-button>
</view>
</template>
<script>
export default {
data() {
return {
classifyList: [],
systemList: [],
brandList: [],
param: {
classifyId: '',
systemId: '',
brandId: '',
},
brandName: '',
selectedAll: false,
}
},
computed: {
list() {
return [{
title: '请选择类别',
type: 'classifyId',
data: this.classifyList
},
{
title: '请选择系统',
type: 'systemId',
data: this.systemList
},
{
title: '请选择品牌',
type: 'brandId',
data: this.brandList
}
]
},
buttonStyle() {
return this.selectedAll ? {
'color': '#FFFFFF',
'background-color': '#2272FF;',
'width': '600rpx',
'height': '104rpx'
} : {
'color': '#FFFFFF',
'background-color': '#D1D4D4;',
'width': '600rpx',
'height': '104rpx'
}
}
},
onLoad(e) {
getApp().trackPage('选择产品页')
this.getRelationDictionaryV2()
},
onShareAppMessage(res) {
let shareObj = {
title: '',
path: '/pages/photo/product',
imageUrl: '',
success() {},
fail() {}
}
return shareObj
},
methods: {
getRelationDictionaryV2: function() {
this.$u.cloudApi.getRelationDictionaryV2().then(res => {
if (res && res.result) {
this.classifyList = res.result
this.param.classifyId = res.result[0].id
this.systemList = res.result[0].child
}
})
},
//选择 点击
itemClick: function(type, item, ikey) {
switch (type) {
case 'classifyId':
this.param = {
classifyId: item.id,
systemId: '',
brandId: ''
}
this.selectedAll = false
this.systemList = this.classifyList[ikey].child
this.brandList = []
break
case 'systemId':
this.param = {
classifyId: this.param.classifyId,
systemId: item.id,
brandId: ''
}
this.selectedAll = false
this.brandList = this.systemList[ikey].child
break
case 'brandId':
this.param.brandId = item.id
this.selectedAll = true
this.brandName = item.name
break
default:
break
}
},
// 点击下一步
handleClick() {
// 点击下一步设置全局拍照品牌品类
if (!this.selectedAll) {
return
}
const globalData = getApp().globalData
// if (!globalData.token) {
// uni.navigateTo({
// url: '/pages/login/wxlogin'
// })
// return
// }
let keys = ['brandId', 'brandName', 'classifyId', 'systemId']
keys.map(key => {
globalData.photo.product[key] = this[key] || this.param[key]
})
uni.navigateTo({
url: '/pages/photo/list' +
'?brandId=' + this.param.brandId +
'&brand=' + this.brandName +
'&classifyId=' + this.param.classifyId +
'&systemId=' + this.param.systemId,
})
}
}
}
</script>
<style>
.backView {
background-color: #F4f5f7;
position: absolute;
top: 0;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
}
.topTitle {
margin-top: 50rpx;
padding-left: 30rpx;
font-size: 36rpx;
font-weight: bold;
color: #333333;
}
.ph-pr-content {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
width: 100%;
padding: 22rpx 22rpx;
}
.ph-pr-arr {
width: 100%;
}
.item-view {
background-color: #FFFFFF;
/* width: 548rpx; */
margin: 0rpx 8rpx 24rpx 8rpx;
/* flex: 1 1 0%;
max-width: 33%; */
width: 222rpx;
height: 76rpx;
display: flex;
align-items: center;
justify-content: center;
border-style: solid;
box-shadow: 0px 2px 7px 0px rgba(0, 0, 0, 0.05);
border-width: 0rpx;
border-radius: 12rpx;
font-size: 26rpx;
color: #666666;
}
.select-item-view {
background-color: #2272FF;
margin: 0rpx 8rpx 24rpx 8rpx;
/* flex: 1 1 0%;
max-width: 33%; */
width: 222rpx;
height: 76rpx;
display: flex;
align-items: center;
justify-content: center;
border-style: solid;
box-shadow: 0px 2px 7px 0px rgba(0, 0, 0, 0.05);
border-width: 0rpx;
border-radius: 12rpx;
font-size: 26rpx;
color: #FFFFFF;
}
.ph-pr-button {
position: absolute;
bottom: 76rpx;
font-size: 32rpx;
}
</style>
<template>
<view class="backView">
<u-loading style="position: fixed;top: 50%;" :show="loading" size="36" mode="flower"></u-loading>
<view class="topView">
<view :class="['topItemView', {'active':activeTop===ikey}]" @click="handleTopItemChange(ikey,item)"
v-for="(item,ikey) in dataList" :key="ikey">
<text :class="['ph-lst-top-index', {'active':activeTop===ikey}]">{{ ikey + 1 }}</text>
<text class="topItemTitle">{{item.type}}</text>
</view>
</view>
<view class="rightView">
<view class="right-view-title">拍照项有:</view>
<template v-for="(item,ikey) in rightList">
<view class="rightItemView" @click="rightItemClick(item,ikey)" :key="ikey">
<view :class="['rightContentView', {'active':item.imageList[0]}]">
<text class="ph-lst-item-index">{{ ikey + 1 }}</text>
<text class="">{{item.name}}</text>
<image class="ph-list-item-arrow" src="/static/photo/arrow.png"></image>
<!-- <text class="rightContent u-m-t-14 u-m-l-30 u-p-b-30">{{item.describe}}</text> -->
</view>
<view class="rightImageView" v-if="item.imageList.length > 0">
<image class="rightImage" v-for="(image, index) in item.imageList.slice(0 , 10)" :src="image"
:key="index" @click.stop="handleClickImage(item, index)" mode="aspectFill"></image>
</view>
</view>
</template>
<u-button v-if="activeTop + 1 === dataList.length" class="ph-list-button" type="error" shape="circle"
:disabled="buttonDisabled" :custom-style="buttonStyle" @click="isPopShow = true">一键清空展示图片</u-button>
</view>
<u-popup border-radius="10" v-model="isPopShow" safe-area-inset-bottom mode="center" width="690rpx"
height="600rpx">
<view class="ph-list-pop-title">
<text>是否一键清空系统展示的图片?</text>
</view>
<view class="ph-list-pop-text">
<text>点击"确定"则删除系统展示的所有图片</text>
</view>
<view class="ph-list-pop-btn-view">
<u-button :custom-style="customStyleCancel" hover-class="none" shape="circle" type="primary"
@click="isPopShow = false">
取消
</u-button>
<u-button :custom-style="customStyleSave" shape="circle" type="primary" @click="handleClickSure()">
确定
</u-button>
</view>
</u-popup>
</view>
</template>
<script>
export default {
data() {
return {
topList: [],
activeTop: 0,
leftList: [],
rightList: [],
classifyId: '',
systemId: '',
brand: '',
brandId: '',
dataList: [],
loading: true,
isPopShow: false
}
},
onLoad(e) {
getApp().trackPage('照片规范列表页')
if (e && e.brandId) {
this.brandId = e.brandId
}
if (e && e.brand) {
this.brand = e.brand
uni.setNavigationBarTitle({
title: this.brand
});
}
if (e && e.systemId) {
this.systemId = e.systemId
}
if (e && e.classifyId) {
this.classifyId = e.classifyId
}
this.getListData()
},
computed: {
buttonStyle() {
return {
'color': '#FFFFFF',
'width': '600rpx',
'height': '104rpx',
'font-size': '36rpx'
}
},
buttonDisabled() {
for (var item of this.dataList) {
for (var i of item.list) {
if ((i.imageList || []).length > 0) {
return false
}
}
}
return true
},
customStyleCancel() {
return {
'background-color': '#D1D4D4',
'width': '280rpx',
'height': '96rpx'
}
},
customStyleSave() {
return {
'background-color': '##2272FF',
'width': '280rpx',
'height': '96rpx',
'margin-left': '50rpx'
}
}
},
methods: {
getListData: function() {
this.loading = true
let that = this
this.$u.cloudApi.getGroupStandardV2({
'token': getApp().globalData.token,
'classify_id': this.classifyId,
'system_id': this.systemId,
'brand_id': this.brandId
}).then(res => {
this.loading = false
if (res && res.result) {
if (res.result.error_code) {
uni.showToast({
title: res.result.error_msg
})
} else {
that.handleData(res.result)
}
}
})
},
handleData: function(result) {
this.activeTop = 0
const globalData = getApp().globalData
globalData.photo.productList = result
this.dataList = result
if (result.length > 0) {
var item = result[0]
globalData.photo.waterSetting = item.userWatermark
this.rightList = item.list
}
},
//顶部点击
handleTopItemChange: function(ikey, item) {
this.activeTop = ikey
this.rightList = item.list
const photo = getApp().globalData.photo
photo.topIndex = ikey
photo.waterSetting = item.userWatermark
uni.pageScrollTo({
scrollTop: 0,
duration: 0
});
},
// 点击图片
handleClickImage(item, index) {
uni.previewImage({
urls: item.imageList,
current: index
})
},
//右侧点击
rightItemClick: function(item, ikey) {
const photo = getApp().globalData.photo
photo.currentItem = item
photo.itemIndex = ikey
const len = item.imageList.length
photo.currentItemLength = len > 9 ? 10 : len
uni.navigateTo({
url: '/pages/photo/take'
})
},
// 清除图片
handleClickSure: function() {
this.$u.cloudApi.cleanImage({
'token': getApp().globalData.token,
}).then(res => {
this.isPopShow = false
if (res && res.result) {
this.getListData()
}
})
}
}
}
</script>
<style>
.backView {
background-color: #F4F5F7;
position: absolute;
top: 0;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
}
.centerBackView {
display: flex;
flex-direction: row;
margin-top: 80rpx;
width: 100%;
}
.ph-lst-top-index {
font-size: 26rpx;
font-weight: bold;
color: #FFFFFF;
border-radius: 8rpx;
background-color: #999999;
width: 36rpx;
height: 36rpx;
line-height: 36rpx;
text-align: center;
}
.ph-lst-top-index.active {
background-color: #2272FF;
}
.rightView {
background-color: #F4F5F7;
width: 100%;
display: flex;
flex-direction: column;
padding-top: 100rpx;
padding-bottom: 50rpx;
}
.right-view-title {
font-size: 36rpx;
font-weight: bold;
height: 104rpx;
line-height: 104rpx;
margin-left: 30rpx;
}
.rightItemView {
/* width: 100%; */
/* display: flex; */
/* flex-direction: row; */
/* justify-content: space-between; */
/* border-bottom: 20rpx solid #F3F3F3; */
margin: 0rpx 30rpx 20rpx 30rpx;
padding: 36rpx 30rpx 30rpx 30rpx;
border-radius: 12rpx;
background-color: #FFFFFF;
/* min-height: 108rpx; */
}
.ph-lst-item-index {
font-size: 24rpx;
font-weight: bold;
border-radius: 4rpx;
width: 34rpx;
height: 34rpx;
line-height: 32rpx;
text-align: center;
border-width: 1px;
border-style: solid;
margin-right: 10rpx;
margin-top: 4rpx;
}
.rightContentView {
display: flex;
align-items: flex-start;
width: 100%;
font-size: 30rpx;
color: #2272FF;
/* flex-direction: column; */
/* border-left: 2rpx solid #F3F3F3; */
}
.rightContentView.active {
color: #666666;
border-color: #666666;
}
.ph-list-item-arrow {
position: absolute;
width: 40rpx;
height: 40rpx;
right: 38rpx;
}
.rightContent {
font-size: 30rpx;
color: #333333;
line-height: 40rpx;
}
.rightImageView {
/* width: 300rpx; */
/* height: 320rpx; */
display: flex;
align-items: center;
justify-content: flex-start;
flex-wrap: wrap;
margin-top: 26rpx;
}
.rightImage {
background-color: #F3F3F3;
width: 116rpx;
height: 116rpx;
margin: 0rpx 12rpx 12rpx 0rpx;
}
.rightImage:nth-child(5n) {
margin-right: 0;
}
.topView {
background-color: #FAFAFA;
width: 100%;
height: 100rpx;
position: fixed;
display: flex;
flex-direction: row;
z-index: 1;
}
.topItemView {
/* width: 210rpx; */
height: 100rpx;
display: flex;
align-items: center;
justify-content: center;
-webkit-flex: 1;
flex: 1;
background-color: #FFFFFF;
color: #999999;
}
.topItemView.active {
color: #2272FF;
}
.topItemTitle {
font-size: 36rpx;
font-weight: bold;
padding-left: 30rpx;
}
.greenBackColor {
background-color: #4CD964;
}
.ph-list-pop-text {
color: #666666;
text-align: center;
margin-top: 20rpx;
font-size: 30rpx;
}
.ph-list-pop-title {
font-size: 40rpx;
padding-top: 150rpx;
text-align: center;
color: #333333;
}
.ph-list-pop-btn-view {
display: flex;
justify-content: center;
margin-top: 150rpx;
}
</style>
<template>
<view>
<view class="contentView">
<u-image class="pic" :src="files[0]" bg-color="transparent" @click="showPreviewFn"></u-image>
<!-- <image class="pic" :src="files[0]" v-lazy mode="aspectFit"></image> -->
</view>
<view class="bottomView">
<image class="btn" :src="btn_remake" @click="$u.throttle(remakePhoto, 3000)"></image>
<image class="btn" :src="btn_continue" @click="$u.throttle(continuePhoto, 3000)"></image>
</view>
<image class="btn finish" src="/static/photo/finish.png" @click="$u.throttle(finishPhoto, 3000)"></image>
</view>
</template>
<script>
import qiniup from '@/components/upload/qiniup';
const app = getApp()
export default {
mixins: [qiniup],
data() {
return {
protocolContent: '',
btn_remake: 'https://qn-static.banshouhui.com/take_order/photo/remake.png',
btn_continue: '/static/photo/continue.png',
standardId: '',
images: [],
files: [],
fileMaps: [],
keys: [],
token: '',
product: '',
}
},
onLoad(e) {
// 获取照片选项对象
const product = app.globalData.photo.product
this.product = `?brandId=${product.brandId}&brand=${product.brandName}&classifyId=${product.classifyId}&systemId=${product.systemId}`
if(app.globalData.photo.currentItem) {
// 获取规格Id
this.standardId = app.globalData.photo.currentItem._id
}
getApp().trackPage('照片预览页')
const globalTempPath = getApp().globalData.photo.tempPath
if(globalTempPath && globalTempPath.mixWater){
this.files = [globalTempPath.mixWater]
}
if(e.standardId) {
this.standardId = e.standardId
}
this.token = getApp().globalData.token
},
methods: {
// 保存照片到本地
async saveTempToLocal(tempImagePath) {
//has_origin //是否保存原图
let that = this
const photo = getApp().globalData.photo
if(!photo.tempPath){
return
}
let path = ''
if(photo.tempPath.origin && photo.waterSetting && photo.waterSetting.has_origin){
// 保存原图到本地
path = photo.tempPath.origin
let result = await this.saveLocal(path)
if(result){
uni.showToast({
icon: 'none',
title: '已将照片原图保存到本地相册'
})
}
}
if(photo.currentItem){
photo.currentItem.imageList.unshift(photo.tempPath.mixWater)
}
// if(photo.productList && photo.productList[photo.topIndex]){
// const topArr = photo.productList[photo.topIndex]
// if(topArr[photo.itemIndex]){
// topArr[photo.itemIndex].imageList.push(photo.tempPath.mixWater)
// }
// }
// photo.
if(photo.tempPath.mixWater){
// 保存水印处理图片到本地
path = photo.tempPath.mixWater
let result1 = await this.saveLocal(path)
if(result1){
uni.showToast({
icon: 'none',
title: '已将水印图片保存到本地相册'
})
}
}
},
saveLocal(path){
return new Promise((resolve,reject)=>{
uni.saveImageToPhotosAlbum({
filePath: path,
success() {
resolve(true)
},
fail() {
reject('保存失败')
}
})
})
},
showPreviewFn(img) {
uni.previewImage({
current: 0,
urls: this.files
});
},
// 重拍图片
remakePhoto() {
uni.navigateBack({
delta:1
})
},
finishPhoto(){
const photo = getApp().globalData.photo
photo.currentItemLength = 10
this.continuePhoto()
// 完成本项
// uni.navigateBack({
// delta:2
// })
},
// 确认图片
continuePhoto() {
let self = this
uni.showLoading({
title:'图片保存中…'
})
self.saveTempToLocal()
self.confirmUpload(true)
},
submitFile() {
let self = this
if(self.keys.length) {
for (let s of self.keys) {
self.$u.cloudApi.saveImage({
"token": self.token,
"standardId": self.standardId,
"url": s,
}).then(async res =>{
console.log(res, "云服务保存图片");
if(res.result.code) {
// TODO 参数是否要来回传递
const photo = getApp().globalData.photo
photo.currentItemLength = photo.currentItemLength + 1
uni.hideLoading()
// 当前项的图片显示
// 拍照项张数目增加 等于10张
if(photo.currentItemLength<10){
uni.navigateBack({
delta:1
})
}else{
uni.navigateBack({
delta:2
})
}
// let timer = setTimeout(()=>{
// if(photo.currentItemLength<10){
// uni.navigateBack({
// delta:1
// })
// }else{
// uni.navigateBack({
// delta:2
// })
// }
// },2000)
} else {
uni.showToast({
title:'图片上传失败 '+ res.result.msg
})
}
})
}
}
},
downloadImages() {
let self = this;
for (let url of this.images) {
uni.downloadFile({
url: url, //仅为示例,并非真实的资源
success(res) {
// 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
if (res.statusCode === 200) {
self.files.push(res.tempFilePath)
}
},
fail(e) {
debugger
}
})
}
},
}
}
</script>
<style lang="scss">
.contentView {
background-color: #333333;
/* padding-top: 120rpx; */
padding-bottom:228rpx;
height: 100vh;
display: flex;
flex-direction: column;
}
/deep/ .u-image{
height:100%!important;
}
/deep/ .u-image__loading{
background-color: transparent!important;
}
/deep/ .u-image__error{
background-color: transparent!important;
}
.pic {
flex:1;
width: 100%;
/* height:auto */
/* height: 760rpx; */
}
.bottomView {
box-shadow: 0 0 1rpx 6rpx rgba(255,255,255,0.05);
background-color: #333333;
width: 100%;
padding:70rpx 0;
position: fixed;
bottom: 0;
display: flex;
justify-content: space-around;
align-items: center;
.btn{
display: block;
width: 200rpx;
height: 88rpx;
}
}
.btn{
display: block;
width: 232rpx;
height: 80rpx;
&.finish{
position: fixed;
top:30rpx;
right:30rpx;
}
}
</style>
<template>
<view class="backView">
<view class="shadowBackView" style="background-color: transparent;z-index: 1" v-if="loading">
<u-loading style="position: fixed;top: 50%;" :show="loading" size="36" mode="flower"></u-loading>
</view>
<view class="itemView firstItem">
<view class="itemTitleView">
<text class="itemTitle">保存原图</text>
<text class="itemNotice">拍照后另保存一张无水印的图片</text>
</view>
<switch class="itemSwitch" :checked="result['has_origin']" @change="handleOrigineChange" color="#007AFF" />
</view>
<view class="itemView" v-if="showTitleSwitch">
<view class="itemTitleView" @click="itemClick({},-1)">
<text class="itemTitle">水印标题</text>
<text class="itemNotice">{{result['lower_right']['title_text'] || '点击可编辑更改'}}</text>
</view>
<switch class="itemSwitch" disabled :checked="result['lower_right']['title_text'] != ''"
@click="handleClickTitleSwitch" color="#007AFF" />
</view>
<view class="itemView" v-for="(item,ikey) in itemList" :key="ikey">
<view class="itemTitleView" @click="itemClick(item,ikey)">
<text class="itemTitle">{{item['watemark_text'] || '自定义' + (ikey + 1)}}</text>
<text class="itemNotice">{{item['watemark_value'] || '点击可编辑更改'}}</text>
</view>
<switch class="itemSwitch" :checked="item['enable']" @change="itemChange(item, ikey)" color="#007AFF" />
</view>
<u-popup border-radius="10" v-model="isPopShow" safe-area-inset-bottom :mask-close-able="false" mode="center"
width="690rpx" height="600rpx" @close="handlePopClose">
<view class="popCenterView">
<text class="popTitle">设置自定义项</text>
<view class="inputBackView">
<view class="ph-pop-left-view">
<view class="leftInputView">
<input class="leftInput" type="text" v-model="currenItem['watemark_text']"
@input="leftInput()" :disabled="currenItem.type === 'title_text'" placeholder="请输入"
maxlength="10" />
</view>
<view class="ph-pop-tip-view" v-if="showTipLeft">*必填项</view>
</view>
<view class="ph-pop-mid-view">:</view>
<view>
<view class="rightInputView">
<input class="rightInput" type="text" v-model="currenItem['watemark_value']"
@input="rightInput()" placeholder="请输入内容" maxlength="30" />
</view>
<view class="ph-pop-tip-view" v-if="showTipRight">*必填项</view>
</view>
</view>
<text class="popNoticeText u-m-t-20">示例:</text>
<text class="popNoticeText">工程队名称:蓝天工程队</text>
<view class="popBtnView">
<u-button :custom-style="customStyleCancel" hover-class="none" shape="circle" type="primary" @click="popCancelClick()">
取消
</u-button>
<u-button :custom-style="customStyleSave" shape="circle" type="primary" @click="popSaveClick()">
保存
</u-button>
</view>
</view>
</u-popup>
</view>
</template>
<script>
export default {
data() {
return {
systemId: '',
isSaveOrigine: true,
isPopShow: false,
icon_close_new: '',
result: {
has_origin: true,
lower_right: {
body: []
}
},
currenItem: {
'watemark_text': '',
'watemark_value': ''
},
editingItem: {},
showTipLeft: false,
showTipRight: false,
loading: true
}
},
computed: {
itemList() {
if (this.result['lower_right']) {
var arr = this.result['lower_right']['body']
return arr.filter((item) => {
return item.watemark_type === '备注'
})
} else {
return []
}
},
showTitleSwitch() {
return this.result['lower_right'].hasOwnProperty('title_text')
},
customStyleCancel() {
return {
'background-color': '#D1D4D4',
'width': '280rpx',
'height': '96rpx'
}
},
customStyleSave() {
return {
'background-color': '##2272FF',
'width': '280rpx',
'height': '96rpx',
'margin-left': '50rpx'
}
}
},
onLoad(e) {
getApp().trackPage('水印设置页')
const globalData = getApp().globalData
this.icon_close_new = globalData.icon_close_new
this.systemId = globalData.photo.product.systemId
this.getItemList()
},
methods: {
getItemList: function() {
// this.systemId = '79550af260555cc20afb34156c94b32c' // 测试数据
this.loading = true
this.$u.cloudApi.getUserWatermark({
'token': getApp().globalData.token,
'system_id': this.systemId
}).then(res => {
if (res && res.result) {
if(res.result.error_code){
uni.showToast({title: res.result.error_msg})
}else{
this.result = res.result
}
}else{
uni.showToast({title: '网络异常'})
}
this.loading = false
})
},
saveUserWatermark: function() {
this.loading = true
this.$u.cloudApi.saveUserWatermark({
'token': getApp().globalData.token,
'watermark': this.result
}).then(res => {
if (res.result.code == true) {
const photo = getApp().globalData.photo
photo.waterSetting = this.result
}else{
uni.showToast({title: res.result.msg})
}
this.loading = false
})
},
//保存原图 开关
handleOrigineChange: function(e) {
this.result['has_origin'] = !this.result['has_origin']
this.saveUserWatermark()
},
handleClickTitleSwitch: function(e) {
var string = this.result['lower_right']['title_text'] ? '水印标题不可关闭' : '请先编辑该自定义项'
uni.showToast({
icon: 'none',
title: string
})
},
//自定义 开关
itemChange: function(item, ikey) {
if (item['watemark_value']) {
// 修改
item['enable'] = !item['enable']
this.saveUserWatermark()
} else {
uni.showToast({
icon: 'none',
title: '请先编辑该自定义项'
})
}
},
//自定义 点击
itemClick: function(item, ikey) {
if (ikey === -1) {
this.currenItem = {
'watemark_text': '水印标题',
'watemark_value': this.result['lower_right']['title_text'],
'type': 'title_text'
}
} else {
this.editingItem = item
this.currenItem = {
...item
}
}
this.isPopShow = true
},
//左侧输入框
leftInput: function(e) {
if (this.currenItem['watemark_text']) {
this.showTipLeft = false
}
},
//右侧输入框
rightInput: function(e) {
if (this.currenItem['watemark_value']) {
this.showTipRight = false
}
},
//自定义弹窗 关闭
popCancelClick: function() {
this.isPopShow = false
this.currenItem = {
'watemark_text': '',
'watemark_value': ''
}
},
handlePopClose() {
this.showTipLeft = false,
this.showTipRight = false
},
//自定义弹窗 保存
popSaveClick: function() {
if (this.currenItem['watemark_text'] && this.currenItem['watemark_value']) {
this.isPopShow = false
if (this.currenItem.type === 'title_text') {
this.result['lower_right']['title_text'] = this.currenItem['watemark_value']
} else {
this.editingItem['watemark_text'] = this.currenItem['watemark_text']
this.editingItem['watemark_value'] = this.currenItem['watemark_value']
this.editingItem['enable'] = true
}
this.saveUserWatermark()
} else {
// 提示
if (!this.currenItem['watemark_text']) {
this.showTipLeft = true
}
if (!this.currenItem['watemark_value']) {
this.showTipRight = true
}
}
}
}
}
</script>
<style>
.backView {
background-color: #FAFAFA;
position: absolute;
top: 0;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
/*
.firstItemView{
background-color: #FFFFFF;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding-top: 80rpx;
padding-bottom: 80rpx;
border-bottom: 2rpx solid #F4F5F7;
} */
.itemView {
background-color: #FFFFFF;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding-top: 54rpx;
padding-bottom: 54rpx;
}
.itemView.firstItem {
border-bottom: 2rpx solid #F4F5F7;
}
.itemTitleView {
background-color: #FFFFFF;
width: 80%;
display: flex;
flex-direction: column;
padding-left: 30rpx;
}
.itemTitle {
font-size: 32rpx;
font-weight: bold;
color: #333333;
}
.itemNotice {
font-size: 26rpx;
color: #666666;
margin-top: 4rpx;
}
.itemSwitch {
margin-right: 30rpx;
transform: scale(0.78, 0.75);
}
.shadowBackView {
background-color: rgba(0, 0, 0, 0.5);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.popCenterView {
background-color: #FFFFFF;
display: flex;
flex-direction: column;
}
.popTitle {
font-size: 36rpx;
font-weight: bold;
margin-top: 50rpx;
padding-left: 30rpx;
}
.inputBackView {
margin-top: 52rpx;
width: 100%;
height: 90rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
display: flex;
align-items: flex-start;
}
.leftInputView {
width: 220rpx;
height: 72rpx;
border: 2rpx solid #666666;
display: flex;
align-items: center;
justify-content: center;
}
.leftInput {
width: 180rpx;
height: 32rpx;
}
.ph-pop-left-view {
margin-left: 30rpx;
}
.ph-pop-tip-view {
color: #F56C6C;
}
.ph-pop-mid-view {
margin-top: 20rpx;
}
.rightInputView {
width: 360rpx;
height: 72rpx;
border: 2rpx solid #666666;
margin-right: 30rpx;
display: flex;
align-items: center;
justify-content: center;
}
.rightInput {
width: 320rpx;
height: 32rpx;
}
.popNoticeText {
font-size: 26rpx;
color: #666666;
padding-left: 30rpx;
}
.popBtnView {
margin-top: 110rpx;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
/* .popCancelBtn {
background-color: #D1D4D4;
width: 280rpx;
height: 96rpx;
border-radius: 48rpx;
margin-left: 40rpx;
display: flex;
align-items: center;
justify-content: center;
} */
/* .popSaveBtn {
background-color: #2272FF;
width: 280rpx;
height: 96rpx;
border-radius: 48rpx;
margin-right: 40rpx;
display: flex;
align-items: center;
justify-content: center;
} */
/* .popBtnText {
font-size: 32rpx;
color: #FFFFFF;
font-weight: 600;
} */
</style>
<template>
<view class="camera-container">
<cover-view class="header-box" :style="{'height':navHeight/2 + 'px'}">
<cover-view class="inner">
<cover-image @click="setCameraInfo('devicePosition')" class="icon" mode="aspectFit"
src="/static/photo/icon-switch.png"></cover-image>
<cover-image @click="setCameraInfo('flash')" class="icon" mode="aspectFit"
:src="'/static/photo/icon-light-' + cameraInfo.flash +'.png'"></cover-image>
<cover-image @click="goPage('/pages/photo/setting')" class="icon" mode="aspectFit"
src="/static/photo/icon-setting.png"></cover-image>
</cover-view>
</cover-view>
<camera class="camera-box" v-if="cameraChange&&!standardShow" v-show="" :device-position="cameraInfo.devicePosition"
:flash="cameraInfo.flash" :style="{'height':cameraHeight/2 + 'px','top':parseInt(navHeight/2) + 'px'}"
@error="cameraError">
<cover-view class="mark-box">
<cover-view class="txt big" v-if="titleTxt">{{titleTxt}}</cover-view>
<cover-view class="txt" v-for="(txt,index) in settingTxtArr" :key="index">{{txt || '获取中'}}</cover-view>
<!-- <cover-view class="txt u-m-t-10">维度:{{waterInfo.latitude || '正在获取中...'}}</cover-view>
<cover-view class="txt u-m-t-10">地址:{{waterInfo.address || '正在获取中...'}}</cover-view>
<cover-view class="txt u-m-t-10">时间:{{waterInfo.date || '正在获取中...'}}</cover-view> -->
</cover-view>
<cover-image class="mark-water" mode="aspectFit" :src="waterInfo.markImage"></cover-image>
</camera>
<cover-view class="bottom-box" v-if="!standardShow">
<cover-image class="icon" src='/static/photo/icon-back.png' mode="" @click="goBack"></cover-image>
<cover-image class='icon-take icon' src='/static/photo/icon-take.png' @click="$u.debounce(takePhoto, 500)"> </cover-image>
<cover-image class='icon' src='/static/photo/icon-standard.png' @click="standardShow = true"> </cover-image>
</cover-view>
<canvas canvas-id="canvas" id="photoCanvas" class="canvas"
:style="{'width':750 + 'rpx','height': cameraHeight + 'rpx'}"></canvas>
<view v-show="standardShow" class="page-mask" :z-index="10000">
<photo-standard :currentItem="currentItem" />
<view class="btn-close">
<image @click="closeShadow" class="icon icon-close" mode="aspectFit" src="/static/photo/icon-close.png">
</image>
</view>
</view>
</view>
</template>
<script>
let r = require("../../libs/bmap-wx.min.js");
let h = new r.BMapWX({
// ak: "rpVq5d3yxaRCoKzVwmFMo0o4iC524CAG",
ak: "lF1HoyXdiv4uZx6TrGQEZs48F5y8kEHI"
});
import standard from '@/components/photo/standard.vue'
export default {
components: {
'photo-standard': standard,
},
data() {
return {
currentItem: {
name: '111',
images: ['https://qn-static.banshouhui.com/live_mark.png',
'https://qn-static.banshouhui.com/live_mark.png',
'https://qn-static.banshouhui.com/live_mark.png'
],
},
standardShow: true,
cameraInfo: {
devicePosition: 'back',
flash: 'auto'
},
waterInfo: {
longitude: '', // 经度
latitude: '', // 维度
address: '', //地址
date: '', //日期
markImage: 'https://qn-static.banshouhui.com/live_mark.png'
},
tempImgs: {
'markImage': '', // 拍照水印
'origin': '', // 无水印照片
'mixWater': '', // 有水印照片
},
authSetting: {
camera: false, // 相机授权
location: false, // 位置授权
},
navHeight: 130,
cameraWidth: 750,
cameraHeight: 1000, // (4 / 3 * 750) 图片比例4:3
ratio: 0,
cameraChange: false,
waterSetting: null,
shadowInitShow: true, // 第一次进入页面需显示弹窗
}
},
onLoad(e) {
const photo = getApp().globalData.photo
console.log(photo, 'global-photo')
getApp().trackPage('拍照页')
// this.ctx = uni.createCameraContext();
this.updateTime()
this.getLocation()
this.getMarkPath()
this.initData()
this.currentItem = photo.currentItem
},
computed: {
titleTxt() {
const waterSetting = this.waterSetting
let txt = ''
if (!waterSetting || !waterSetting.lower_right) {
return ''
}
txt = waterSetting.lower_right && waterSetting.lower_right.title_text || ''
return txt
},
settingTxtArr() {
let arr = []
// 包含经纬度
const waterInfo = this.waterInfo
arr = ['经度:' + waterInfo.longitude, '纬度:' + waterInfo.latitude, '地址:' + waterInfo.address, '时间:' +
waterInfo.date
]
let settingTxtArr = []
const typeArr = ['经度', '纬度', '地址', '时间']
const waterSetting = this.waterSetting
if (!waterSetting || !waterSetting.lower_right || !waterSetting.lower_right.body) {
return arr
}
const settingArr = waterSetting.lower_right.body
settingArr.map(item => {
const idx = typeArr.indexOf(item.watemark_type)
if (item.enable && (idx > -1 || (item.watemark_value && item.watemark_text))) {
if (idx > -1) {
settingTxtArr.push(arr[idx])
} else {
settingTxtArr.push(item.watemark_text + ':' + item.watemark_value)
}
}
})
return settingTxtArr
}
},
watch: {},
onShow() {
// 默认开启弹窗
const photo = getApp().globalData.photo
this.waterSetting = photo.waterSetting
this.standardShow = this.shadowInitShow
this.cameraChange = true
// this.initData()
},
onHide(){
this.cameraChange = false
},
methods: {
closeShadow() {
this.shadowInitShow = false
this.standardShow = false
},
goBack() {
uni.navigateBack({
delta: 1
})
// uni.redirectTo({
// url: '/pages/photo/list'
// })
},
goPage(url) {
url = url || '/pages/photo/index';
uni.navigateTo({
url: url
})
},
updateTime() {
this.waterInfo.date = this.getTime()
// let timer = setTimeout(() => {
// clearTimeout(timer);
// this.updateTime()
// }, 1000)
},
setCameraInfo(type) {
// 设置相机前置后置、闪关灯等
const cameraInfo = this.cameraInfo
let val = cameraInfo[type]
switch (type) {
case 'devicePosition':
val = val === 'back' ? 'front' : 'back'
break;
case 'flash':
val = val === 'auto' ? 'on' : (val === 'on' ? 'off' : 'auto')
break;
defalut:
break;
}
this.cameraInfo[type] = val
},
initData() {
const globalData = getApp().globalData
this.navHeight = globalData.navHeight
this.cameraHeight = parseInt(globalData.safeHeight*2 - globalData.navHeight - 200) ;
// console.log(globalData.safeHeight,'globalData.safeHeight')
// console.log(this.cameraHeight,'this.cameraHeight')
// console.log(globalData.navHeight,'globalData.navHeight')
this.ratio = globalData.screenHeight / globalData.rpxScreenHeight
// console.log(globalData.screenHeight,globalData.rpxScreenHeight,this.ratio)
this.waterSetting = globalData.photo.waterSetting
// this.cameraHeight = globalData.rpxScreenHeight
},
baiduLocation() {
// 百度sdk解析经纬度
let waterInfo = this.waterInfo
const t = function() {
let t = {
success: function(res) {
let e = res.wxMarkerData[0];
let i = e.address;
waterInfo.address = i
},
fail: function(err) {
// console.log(err, 'err')
}
};
if (waterInfo.latitude && waterInfo.longitude) {
let e = waterInfo.latitude + "," + waterInfo.longitude;
t.location = e;
}
h.regeocoding(t);
};
t()
},
cameraError(e) {
const {
errMsg
} = e.detail
// console.log(e.detail, 'e.detail')
if (errMsg !== 'insertCamera:fail auth deny') {
return
}
this.showSettingModal('camera')
},
//获取位置
getLocation() {
let that = this
const waterInfo = this.waterInfo
uni.getLocation({
type: 'gcj02',
success: function(res) {
waterInfo.longitude = parseFloat(res.longitude).toFixed(4)
waterInfo.latitude = parseFloat(res.latitude).toFixed(3)
// console.log(waterInfo.longitude, 'that.longitude', waterInfo.latitude, 'that.latitude')
that.baiduLocation()
},
fail(err) {
that.showSettingModal('location')
// that.showLocationAuthModal('')
}
});
},
showSettingModal(type) {
// console.log(type, 'showModal-type')
type = type || 'camera'
const self = this
let authSetting = {
'camera': {
content: '将无法进行拍照',
method: ''
},
'location': {
content: '将无法定位当前位置',
method: ''
},
'writePhotosAlbum': {
content: '将无法保存图片到本地',
method: ''
}
}
let content = authSetting[type].content
uni.showModal({
content: '拒绝授权' + content + ',是否去设置打开?',
confirmText: "确认",
cancelText: '取消',
success(res) {
if (res.confirm) {
self.openSetting()
}
},
fail() {}
})
},
openSetting() {
// 打开设置
let self = this
this.cameraChange = false
wx.openSetting({
success(res) {
const authSetting = res.authSetting
self.cameraChange = true
if (authSetting['scope.userLocation']) {
// 位置授权成功
self.authSetting.location = true
self.getLocation()
}
if (res.authSetting['scope.camera']) {
self.authSetting.camera = true
}
if (res.authSetting['scope.writePhotosAlbum']) {
self.authSetting.writePhotosAlbum = true
}
}
})
},
//获取 水印 本地缓存路径
getMarkPath: function() {
uni.downloadFile({
url: this.waterInfo.markImage, //仅为示例,并非真实的资源
success: (res) => {
if (res.statusCode === 200) {
this.tempImgs.markImage = res.tempFilePath
}
},
fail() {
console.log('水印图片 下载失败')
}
})
},
/* ---------------------- 拍照流程 ---------------------- */
// 第一步:拍照
takePhoto() {
wx.createCameraContext().takePhoto({
quality: "high"
}).then(res => {
this.tempImgs.origin = res.tempImagePath
this.drawCanvas(res.tempImagePath)
})
},
// 第二步:绘制画布
drawCanvas: function(tempPath) {
uni.showLoading({
title: '数据处理中...',
icon: 'loading'
})
const waterSetting = this.waterSetting
const globalTempPath = getApp().globalData.photo.tempPath
const ratio = this.ratio
console.log(this.ratio,'this.ratio')
// const ratio = 0.5
let canvasWidth = this.cameraWidth * ratio
let canvasHeight = this.cameraHeight * ratio
const waterInfo = this.waterInfo
this.showImage = true
const settingTxtArr = this.settingTxtArr
//将原图画到canvas上面
let canvas = uni.createCanvasContext("canvas", this)
canvas.rect(0, 0, canvasWidth, canvasHeight)
canvas.drawImage(tempPath, 0, 0, canvasWidth, canvasHeight)
// this.canvas.draw()
let txtHeight = 18
let h = 1
//加入 水印文字
for (let i = settingTxtArr.length - 1; i >= 0; i--) {
txtHeight = 20
canvas.setFontSize(15)
canvas.setFillStyle('#f2f2f2')
let txt = settingTxtArr[i]
if(txt.indexOf('时间')>=0){
canvas.fillText(txt, 10, canvasHeight - txtHeight * h++);
}else{
if(txt.length>22){
canvas.fillText(txt.substr(22,22), 10, canvasHeight - txtHeight * h++);
canvas.fillText(txt.substr(0,22), 10, canvasHeight - txtHeight * h++);
}else{
canvas.fillText(txt, 10, canvasHeight - txtHeight * h++);
}
}
// canvas.fillText(txt, 10, canvasHeight - txtHeight * h++);
}
const title = this.titleTxt
if (title) {
canvas.save()
let titleHeight = title.length > 14 ? 60 : 30
let rectWidth = title.length > 14 ? 215 : title.length*10
canvas.setFillStyle('rgba(34, 114, 255, 0.6)')
canvas.fillRect(10, canvasHeight - txtHeight * h - titleHeight, 215, titleHeight)
canvas.restore()
canvas.setFontSize(20)
canvas.setFillStyle('#f2f2f2')
// canvas.setTextAlign('center')
if (title.length > 14) {
canvas.fillText(title.substr(14, 14), 10, canvasHeight - txtHeight * h++ + 20);
}
canvas.fillText(title.substr(0, 14), 10, canvasHeight - txtHeight * h++ - titleHeight / 2 + 10);
}
if (this.waterSetting && this.waterSetting.mid_text) {
//加入 水印图片
canvas.drawImage(this.tempImgs.markImage, canvasWidth / 2 - 100, canvasHeight / 2 - 25, 200, 50)
}
// canvas.drawImage(this.tempImgs.markImage, canvasWidth / 2 - 100, canvasHeight / 2 - 25, 200, 50)
canvas.draw(false,
setTimeout(() => {
uni.canvasToTempFilePath({
width: canvasWidth,
height: canvasHeight,
canvasId: 'canvas',
success: (res) => {
this.tempImgs.mixWater = res.tempFilePath
globalTempPath.origin = this.tempImgs.origin
globalTempPath.mixWater = res.tempFilePath
let timer = setTimeout(()=>{
this.goPage('/pages/photo/preview')
},0)
// this.saveToLocal(res.tempFilePath)
},
fail: (res) => {
console.log(res);
},
complete: () => {
uni.hideLoading();
}
}, this);
}, 50))
},
// 第三步:保存到本地
saveToLocal(tempImagePath) {
//has_origin //是否保存原图
let that = this
uni.saveImageToPhotosAlbum({
filePath: tempImagePath,
success() {
uni.showToast({
icon: 'none',
title: '已将照片保存到本地相册'
})
},
fail() {}
})
},
showPreviewFn(img) {
uni.previewImage({
current: 0,
urls: [img]
});
},
//获取当前时间
getTime: function() {
let d = new Date();
let year = d.getFullYear();
let month = d.getMonth() + 1;
let date = d.getDate();
let days = new Array("日", "一", "二", "三", "四", "五", "六");
let day = d.getDay();
let hour = (d.getHours() < 10) ? ("0" + d.getHours()) : d.getHours();
let min = (d.getMinutes() < 10) ? ("0" + d.getMinutes()) : d.getMinutes();
let sec = (d.getSeconds() < 10) ? ("0" + d.getSeconds()) : d.getSeconds();
let now = year + "年" + month + "月" + date + "日 " + hour + ":" + min + ":" + sec;
return now
},
}
}
</script>
<style scoped lang="scss">
.camera-container {
// padding-top:var(--status-bar-height);
min-height: 100vh;
background-color: black;
}
.header-box {
// padding:10rpx 20rpx;
position: relative;
.inner {
display: flex;
position: absolute;
left: 0;
right: 0;
bottom: 0;
}
.icon {
margin: 20rpx;
display: block;
width: 44rpx;
height: 44rpx;
}
}
.camera-box {
position: absolute;
left:0;
width: 100%;
// height: 100vh;
z-index: 1;
}
.mark-water {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 360rpx;
height: 90rpx;
z-index: 6;
}
.mark-box {
position: absolute;
left: 0;
bottom: 0;
padding: 20rpx;
.txt {
max-width: 500rpx;
max-height: 80rpx;
overflow: hidden;
margin-top: 5rpx;
line-height: 40rpx;
white-space: normal;
font-size: 28rpx;
color: #fff;
&.big {
padding: 10rpx;
margin-bottom: 10rpx;
width: 430rpx;
line-height: 40rpx;
font-size: 32rpx;
background-color: rgba(34, 114, 255, 0.6);
}
}
}
.bottom-box {
position: absolute;
left: 0;
right: 0;
bottom:0;
// bottom: constant(safe-area-inset-bottom);
// bottom: env(safe-area-inset-bottom);
z-index: 5;
box-sizing: border-box;
height: 200rpx;
display: flex;
justify-content: space-between;
padding: 20rpx 78rpx;
align-items: center;
background-color: black;
.txt {
white-space: nowrap;
line-height: 60rpx;
color: #fff;
}
.icon {
display: block;
width: 92rpx;
height: 92rpx;
&.icon-take {
width: 144rpx;
height: 144rpx;
}
}
}
.canvas {
position: fixed;
left: -750rpx;
top: 0;
}
// 拍照规范
.page-mask {
position: fixed;
bottom: 0;
bottom: constant(safe-area-inset-bottom);
bottom: env(safe-area-inset-bottom);
z-index: 1000;
width: 750rpx;
height: 100vh;
// padding: 0 30rpx;
box-sizing: border-box;
background-color: rgba(0, 0, 0, 0.8);
.icon {
width: 92rpx;
height: 92rpx;
}
.btn-close {
position: absolute;
bottom: 0;
bottom: constant(safe-area-inset-bottom);
bottom: env(safe-area-inset-bottom);
left: 0;
right: 0;
height: 200rpx;
z-index: 100;
display: flex;
justify-content: center;
align-items: center;
}
}
</style>
......@@ -18,7 +18,7 @@
mode="aspectFill"
v-for="(src, key) in fileItem.placeholderImages"
:src="fileItem.imgs.length > key ? fileItem.imgs[key] : src"
:key="src + key"
:key="key"
@click="handleClick(fileItem, index, key)"
></image>
</view>
......
......@@ -76,9 +76,57 @@ function signup(data) {
}
function oauth() {
return new Promise(function (resolve, reject) {
uni.getProvider({
service: 'oauth',
success: function (res) {
console.log(res.provider)
if (~res.provider.indexOf('weixin')) {
// weixin 微信登录
login('weixin').then(res=>{resolve(res)}).catch(err=>{reject(err)})
} else if (~res.provider.indexOf('qq')) {
// qq QQ登录
login('qq').then(res=>{resolve(res)}).catch(err=>{reject(err)})
} else if (~res.provider.indexOf('sinaweibo')) {
// sinaweibo 新浪微博登录
login('sinaweibo').then(res=>{resolve(res)}).catch(err=>{reject(err)})
} else if (~res.provider.indexOf('xiaomi')) {
// xiaomi 小米登录
login('xiaomi').then(res=>{resolve(res)}).catch(err=>{reject(err)})
} else if (~res.provider.indexOf('univerify')) {
// univerify 一键登录 App
login('univerify').then(res=>{resolve(res)}).catch(err=>{reject(err)})
} else if (~res.provider.indexOf('apple')) {
// apple Apple登录
login('apple').then(res=>{resolve(res)}).catch(err=>{reject(err)})
}
}
});
});
}
function login(provider) {
return new Promise(function (resolve, reject) {
uni.login({
provider: provider,
success(res) {
console.log(JSON.stringify(res));
resolve(res);
},
fail(err) {
console.log(JSON.stringify(err));
reject(err);
}
});
});
}
module.exports = {
appLogin: appLogin,
authorization: authorization,
signup: signup
signup: signup,
oauth: oauth
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment