Commit c01b56ca authored by jyx's avatar jyx

处理跨域,添加登录,认证页

parent 2eeb036c
......@@ -112,8 +112,8 @@
titlePadding: 8,
windowWidth: 0,
bottomSafePadding: 12,
h5Url: 'https://api.mints-id.com/index.html',
baseUrl: 'https://dx.mints-tech.cn/minip-api/miniApi',
h5Url: 'https://api.mints-tech.cn/camera-api',
baseUrl: 'https://api.mints-tech.cn/camera-api',
// baseUrl: 'http://test.mints-id.com/ww-new/api',
titleButtonWidth: 38,
token: '',
......
import {
post,
get
} from '../net/httpFetch.js'
module.exports = {
/**
* 我的
*/
baseMsg(params) {
return post('roseApi/user/baseMsg', params)
},
/**
* 手机号登录
*/
mobileLogin(params) {
return post('roseApi/user/mobilelogin/h5', params)
},
/**
* 获取验证码
*/
sendMobileCode(params) {
return post('roseApi/user/sendMobileCode', params)
},
/**
* 获得人脸核验url
*/
getWxFaceParam(params) {
return post('roseApi/face/getWxFaceParam', params)
},
/**
* 返回人脸核验url,跳转后录制视频
*/
faceResult(params) {
return post('roseApi/face/faceResult', params)
},
}
\ No newline at end of file
// 定义 UserProfile 对象
export const UserProfile = {
PROFILE_SG: {
str: "身高",
arr: getHeightArr(),
},
PROFILE_TZ: {
str: "体重",
arr: getWeightArr(),
},
PROFILE_SX: {
str: "身形",
arr: ["大长腿", "A4腰", "丰满", "锁骨", "微胖", "170CM"],
},
PROFILE_JYFW: {
str: "交友范围",
arr: [],
},
PROFILE_ZY: {
str: "职业",
arr: [{
"name": "无",
"children": [
{"name": "无"},
]
},
{
"name": "娱乐体育",
"children": [
{"name": "影视"},
{"name": "运动体育"},
{"name": "音乐"},
{"name": "模特"},
]
},
{
"name": "工程制造",
"children": [
{"name": "建筑"},
{"name": "土木工程"},
{"name": "机械制造"},
{"name": "电子"},
{"name": "生物医药"},
{"name": "食品"},
{"name": "服饰"},
{"name": "能源"},
]
},
{
"name": "金融保险",
"children": [
{"name": "投资"},
{"name": "股票/基金"},
{"name": "保险"},
{"name": "银行"},
{"name": "信托/担保"},
]
},
{
"name": "交通运输",
"children": [
{"name": "航空"},
{"name": "铁路"},
{"name": "航运/船舶"},
{"name": "公共交通"},
{"name": "物流运输"},
]
},
{
"name": "信息技术",
"children": [
{"name": "互联网"},
{"name": "IT"},
{"name": "通讯"},
{"name": "电信运营"},
{"name": "网络游戏"},
]
},
{
"name": "文化传播",
"children": [
{"name": "媒体出版"},
{"name": "设计"},
{"name": "文化传播"},
{"name": "广告创意"},
{"name": "动漫"},
{"name": "公关/会展"},
{"name": "摄影"},
]
},
{
"name": "公共事业",
"children": [
{"name": "医疗"},
{"name": "法律"},
{"name": "教育"},
{"name": "科研"},
{"name": "公益"},
]
},
{
"name": "商业服务",
"children": [
{"name": "咨询"},
{"name": "个体经营"},
{"name": "美容美发"},
{"name": "旅游"},
{"name": "酒店餐饮"},
{"name": "贸易"},
{"name": "汽车"},
{"name": "物业管理"},
{"name": "装修/装潢"},
{"name": "侦探"},
]
}
],
},
PROFILE_GXBQ: {
str: "个性标签",
arr: [],
},
PROFILE_NL: {
str: "年龄",
arr: getAgeArr(),
},
PROFILE_JYJM: {
str: "交友节目",
arr: [
"旅游",
"夜蒲聚会",
"兜风",
"游艇派对",
"玩游戏",
"运动",
"看电影",
"去唱歌",
"吃吃喝喝",
],
},
UNKNOWN: {
str: "未知",
arr: null,
},
USUAL_LABEL_MALE: {
str: "日常",
arr: [
{"name": "泡吧","s": false},
{"name": "不抽烟","s": false},
{"name": "旅游","s": false},
{"name": "聚会","s": false},
{"name": "不喝酒","s": false},
{"name": "酒神","s": false},
{"name": "吃货","s": false},
{"name": "游戏","s": false},
{"name": "本科","s": false},
{"name": "宅家","s": false},
{"name": "蹦迪","s": false},
{"name": "看脸","s": false},
{"name": "健身","s": false},
{"name": "读书","s": false},
{"name": "上班","s": false},
],
},
SPECIAL_LABEL_MALE: {
str: "特质",
arr: [
{"name": "硬汉","s": false},
{"name": "大方","s": false},
{"name": "暖男","s": false},
{"name": "文艺","s": false},
{"name": "会玩","s": false},
{"name": "随性","s": false},
{"name": "只走心","s": false},
{"name": "浪漫","s": false},
{"name": "阳光","s": false},
{"name": "直爽","s": false},
{"name": "磁性","s": false},
{"name": "小鲜肉","s": false},
{"name": "高素质","s": false},
{"name": "爱干净","s": false},
{"name": "磁性","s": false},
{"name": "腹肌","s": false},
],
},
USUAL_LABEL_FEMALE: {
str: "日常",
arr: [
{"name": "泡吧","s": false},
{"name": "不抽烟","s": false},
{"name": "旅游","s": false},
{"name": "聚会","s": false},
{"name": "不喝酒","s": false},
{"name": "酒神","s": false},
{"name": "吃货","s": false},
{"name": "游戏","s": false},
{"name": "本科","s": false},
{"name": "宅家","s": false},
{"name": "Cosplay","s": false},
{"name": "颜控","s": false},
{"name": "细节控","s": false},
{"name": "声控","s": false},
{"name": "手控","s": false},
],
},
SPECIAL_LABEL_FEMALE: {
str: "特质",
arr: [
{"name": "老司机","s": false},
{"name": "气质","s": false},
{"name": "性感","s": false},
{"name": "会玩","s": false},
{"name": "高冷","s": false},
{"name": "嗲妹子","s": false},
{"name": "清纯","s": false},
{"name": "萝莉","s": false},
{"name": "妩媚","s": false},
{"name": "百变","s": false},
{"name": "直爽","s": false},
{"name": "随性","s": false},
{"name": "萌萌哒","s": false},
{"name": "爱干净","s": false},
{"name": "比较乖","s": false},
],
},
SPECIAL_LIKE_FEMALE: {
str: "喜欢的女生特质",
arr: [
{"name": "泡吧","s": false},
{"name": "不抽烟","s": false},
{"name": "cosplay","s": false},
{"name": "游戏","s": false},
{"name": "不喝酒","s": false},
{"name": "酒神","s": false},
{"name": "吃货","s": false},
{"name": "老司机","s": false},
{"name": "气质","s": false},
{"name": "性感","s": false},
{"name": "会玩","s": false},
{"name": "高冷","s": false},
{"name": "嗲妹子","s": false},
{"name": "清纯","s": false},
{"name": "萝莉","s": false},
{"name": "妩媚","s": false},
{"name": "百变","s": false},
{"name": "直爽","s": false},
{"name": "随性","s": false},
{"name": "萌萌哒","s": false},
{"name": "爱干净","s": false},
{"name": "比较乖","s": false},
],
},
};
// 生成体重数组
function getWeightArr() {
const start = 30;
const end = 120;
const arr = [];
for (let i = start; i <= end; i++) {
arr.push(`${i}KG`);
}
return arr;
}
// 生成身高数组
function getHeightArr() {
const start = 140;
const end = 230;
const arr = [];
for (let i = start; i <= end; i++) {
arr.push(`${i}CM`);
}
return arr;
}
// 生成年龄数组
function getAgeArr() {
const start = 1975;
const end = 2006;
const arr = [];
for (let i = start; i <= end; i++) {
arr.push(`${i}`);
}
return arr;
}
\ No newline at end of file
const CryptoJS = require('./crypto-js.js')
const key = CryptoJS.enc.Utf8.parse("abcdnnnnnn123456"); //十六位十六进制数作为密钥
var iv = CryptoJS.enc.Utf8.parse('3266e4c9b8138d3b'); //十六位 aes转换后使用
/**
* 加密(需要先加载lib/aes/aes.min.js文件)
* @param word
* @returns {*}
*/
export function encrypt(word) {
var srcs = CryptoJS.enc.Utf8.parse(word);
var encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
let ens = encrypted.ciphertext.toString(CryptoJS.enc.Base64)
return ens;
}
/**
* 解密
* @param word
* @returns {*}
*/
export function decrypt(word) {
// 去除 换行符 空格 下划线
var replaceWord = word.replace(/[\r\n]/g, "").replace(/\-g/, '+').replace(/_/, '/');
//返回的是解密后的对象
let decrypt = CryptoJS.AES.decrypt(replaceWord, key, {
iv: iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
//将解密对象转换成UTF8的字符串
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
// 返回解密结果
return decryptedStr.toString();
}
\ No newline at end of file
This diff is collapsed.
import {
encrypt,
decrypt
} from '../encry/aesUtil.js'
import md5 from 'js-md5'
import {
encode,
decode
} from 'js-base64';
import {
removeUserInfo
} from '../store/user.js';
const optionsUrl = {
isDebug: process.env.NODE_ENV === 'development',
devUrl: "",
prodUrl: "https://api.mints-tech.cn/camera-api/"
}
const API_ROOT = optionsUrl.isDebug ? optionsUrl.devUrl : optionsUrl.prodUrl
const headers = {
'token': '',
'version': '1.0.0',
'pkgName': 'com.duben.loveplayletd',
'channel': 'h5',
'Content-Type': 'application/json',
}
function getAuth() {
return new Promise((resolve, reject) => {
uni.getStorage({
key: 'TOKEN_ID',
success: function(data) {
headers.token = data
resolve(true)
},
fail: function(data, code) {
resolve(false)
}
})
})
}
function realFetch(url, data = null, method = 'get') {
// 打印日志
console.log('┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
console.log('┃ REQUEST ')
console.log('┃ url: ', API_ROOT + url)
console.log('┃ method: ', method)
console.log('┃ data: ', JSON.stringify(data))
console.log('┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')
var token = headers.token
var time = '' + new Date().getTime()
var jsonData = JSON.stringify(data)
var channel = 'quick_' + 'scan'
var _sign = token + ':' + channel + ':' + time
var sign = '' + md5(_sign)
var check = '' + md5(_sign + ':' + jsonData)
var params = {
'channel': channel,
'sign': sign,
'check': check,
'data': encrypt(jsonData)
}
let option = {}; // 请求参数
option.url = API_ROOT + url
option.method = method
option.data = encrypt(jsonData)
headers['last-session'] = encode(time) // base64 编码
headers['new-session'] = md5(time) // md5 加密
option.header = {
...headers
}
return new Promise((resolve, reject) => {
uni.request({
...option,
success: (data) => {
console.log(data)
var result = {}
if (typeof data.data === 'object') {
result = data.data
} else {
let result = JSON.parse(data.data)
}
console.log(
'┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
)
console.log('┃ RESULT: ')
console.log('┃ url: ', API_ROOT + url)
console.log('┃ method: ', method)
console.log('┃ status: ', result.status ?? '')
console.log('┃ message: ', result.message ?? '')
console.log('┃ data: ', result.data != undefined ? decrypt(result.data ?? '') : "")
console.log(
'┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
)
if (result.status == 200) {
if (result.data != undefined) {
resolve(decrypt(result.data))
} else {
resolve(result.message ?? '')
}
} else if (result.status == 401) {
removeUserInfo()
// token失效
reject(result.message)
} else {
reject(result.message)
}
},
fail: (error) => {
reject(error)
}
})
})
}
function withAuth(url, data = null, method = 'get', canSkip = false) {
return getAuth().then((auth) => {
if (auth || canSkip) {
return realFetch(url, data, method)
} else {
return realFetch(url, data, method)
}
})
}
function post(url, data = null, config = {}) {
return withAuth(url, data, 'post', config.canSkip)
}
function get(url, data = null, config = {}) {
return withAuth(url, data, 'get', config.canSkip)
}
module.exports = {
post,
get
}
\ No newline at end of file
export function setUserInfo(obj) {
uni.setStorageSync('TOKEN_ID', obj.token)
uni.setStorageSync('MOBILE', obj.mobile)
uni.setStorageSync('USER_ID', obj.pk_id)
uni.setStorageSync('CODE_ID', obj.idcode)
uni.setStorageSync('NICK_NAME', obj.nickName)
uni.setStorageSync('HEAD', obj.head)
uni.setStorageSync('OPENID', obj.openId)
uni.setStorageSync('ACTIVITE_FLAG', obj.activiteFlag == 1)
uni.setStorageSync('USER_GET_ONE_HOUR_VIP', obj.userGetOneHourVip)
uni.setStorageSync('IS_FOREVER', obj.isForever)
uni.setStorageSync('EXPIRE_TIME', obj.expireTime)
if (obj.expireTime > 0) {
uni.setStorageSync('VIP_FLAG', true)
} else {
uni.setStorageSync('VIP_FLAG', false)
}
// uni.setStorageSync('CREATE_TIME', obj.createTime)
if (obj.mobile != null || obj.mobile != '' || obj.openId != null || obj.openId != '') {
uni.setStorageSync('IS_TEMP_USER', false)
} else {
uni.setStorageSync('IS_TEMP_USER', true)
}
}
export function setBaseMsg(obj) {
uni.setStorageSync('MOBILE', obj.mobile)
uni.setStorageSync('USER_ID', obj.pk_id)
uni.setStorageSync('CODE_ID', obj.idcode)
uni.setStorageSync('NICK_NAME', obj.nickName)
uni.setStorageSync('HEAD', obj.head)
uni.setStorageSync('OPENID', obj.openId)
uni.setStorageSync('ACTIVITE_FLAG', obj.activiteFlag == 1)
uni.setStorageSync('USER_GET_ONE_HOUR_VIP', obj.userGetOneHourVip)
uni.setStorageSync('IS_FOREVER', obj.isForever)
uni.setStorageSync('EXPIRE_TIME', obj.expireTime)
if (obj.expireTime > 0) {
uni.setStorageSync('VIP_FLAG', 1)
} else {
uni.setStorageSync('VIP_FLAG', 0)
}
// uni.setStorageSync('CREATE_TIME', obj.createTime)
if (obj.mobile != null || obj.mobile != '' || obj.openId != null || obj.openId != '') {
uni.setStorageSync('IS_TEMP_USER', false)
} else {
uni.setStorageSync('IS_TEMP_USER', true)
}
}
export function removeUserInfo() {
// 清空
uni.clearStorage()
}
export function setMobile(obj) {
uni.setStorageSync('MOBILE', obj.mobile)
}
export function initUser() {
uni.getStorage('TOKEN_ID')
.then((data) => {
user.token = data
})
.catch((err) => {
user.token = ''
})
uni.getStorage('MOBILE')
.then((data) => {
user.mobile = data
})
.catch((err) => {
user.mobile = ''
})
uni.getStorage('USER_ID')
.then((data) => {
user.uid = data
})
.catch((err) => {
user.uid = ''
})
uni.getStorage('IS_TEMP_USER')
.then((data) => {
user.isTempUser = data
})
.catch((err) => {
user.isTempUser = ''
})
uni.getStorage('CODE_ID')
.then((data) => {
user.codeId = data
})
.catch((err) => {
user.codeId = ''
})
uni.getStorage('ACTIVITE_FLAG')
.then((data) => {
user.activiteFlag = data
})
.catch((err) => {
user.activiteFlag = false
})
uni.getStorage('USER_GET_ONE_HOUR_VIP')
.then((data) => {
user.userGetOneHourVip = data
})
.catch((err) => {
user.userGetOneHourVip = ''
})
uni.getStorage('IS_FOREVER')
.then((data) => {
user.isForever = data
})
.catch((err) => {
user.isForever = ''
})
uni.getStorage('NICK_NAME')
.then((data) => {
user.nickName = data
})
.catch((err) => {
user.nickName = ''
})
uni.getStorage('HEAD')
.then((data) => {
user.head = data
})
.catch((err) => {
user.head = ''
})
uni.getStorage('OPENID')
.then((data) => {
user.openId = data
})
.catch((err) => {
user.openId = ''
})
uni.getStorage('VIP_FLAG')
.then((data) => {
user.vipFlag = data
})
.catch((err) => {
user.vipFlag = 0
})
uni.getStorage('EXPIRE_TIME')
.then((data) => {
user.expireTime = data
})
.catch((err) => {
user.expireTime = 0
})
return user
}
export var user = {
token: '', // Token
mobile: '', // 手机号
uid: '', // 用户id
isTempUser: '', // 游客或登录用户
codeId: '', // 用户code
nickName: '', // 昵称
head: '', // 头像
openId: '', // 微信openId
activiteFlag: '', // 匹配用户
userGetOneHourVip: '', // 应用市场弹窗
isForever: '', // 永久会员
expireTime: '', // 会员到期时间
vipFlag: '', // 会员
}
\ No newline at end of file
This diff is collapsed.
<template>
<picker @change="pickerChange" @columnchange="columnchange" :range="array" range-key="name" :value="value"
mode="multiSelector">
<slot></slot>
</picker>
</template>
<script>
import AllAddress from './AddressData.js'
import {
UserProfile
} from '@/common/constant/userProfile.js';
export default {
data() {
return {
value: [],
array: [],
index: 0
}
},
props: {
level: { //级数
type: Number,
default: 3
},
},
created() {
this.init()
},
methods: {
// 初始化地址选项
init() {
this.array = new Array(this.level);
for (let i = 0; i < this.array.length; i++) {
if (i == 0) {
// this.array[i] = AllAddress
this.array[i] = UserProfile.PROFILE_ZY.arr
} else {
this.array[i] = [];
if (this.array[i - 1][0].children != null) {
this.array[i] = this.array[i - 1][0].children;
}
}
}
this.$forceUpdate()
},
// 地址控件改变控件
columnchange(e) {
let aIndex = JSON.parse(JSON.stringify(e.detail.column + 1)); //第几组
let j = e.detail.value; //索引值
// console.log('e.detail',e.detail)
// console.log('选择:第'+ aIndex +'组,索引值为第' +j +'个 值为'+this.array[aIndex-1][j].name);
for (let i = aIndex; i < this.array.length; i++) {
//选的第几组 和索引值
//1、选第一组 children 默认第二组的第一个,第三组的值为第二组的第一个children
//2、选第二组 children 默认第三组的值为第二组的选中的children第一个值
this.array[i] = [];
console.log('this.array[i] ', i, )
if (e.detail.column === 0 && i === 2) {
if (this.array[i - 1][0].children != null) {
this.array[i] = this.array[i - 1][0].children;
}
} else {
if (this.array[i - 1][j].children != null) {
this.array[i] = this.array[i - 1][j].children;
}
}
// console.log('this.array[i] ',this.array[i] )
}
this.$forceUpdate();
},
//点击确定
pickerChange(e) {
var result = [];
for (let i = 0; i < this.array.length; i++) {
result.push({
name: this.array[i][e.target.value[i]].name,
id: this.array[i][e.target.value[i]].id
})
};
this.$emit('change', {
data: result
})
}
}
}
</script>
<style>
</style>
\ No newline at end of file
This diff is collapsed.
export default {
data() {
return {
method: 'GET',
url: '',
info: {}
};
},
onUnload() {
this.info = {}
},
methods: {
getData() {
return {};
},
dataLoaded() {},
loadData() {
let {
method,
url
} = this;
let data = this.getData();
this[method.toLowerCase()]({
url,
data,
success: ({
result
}) => {
this.info = result;
// console.log(result)
this.dataLoaded();
}
})
}
}
};
// export default {
// created() {
// //#ifdef MP-WEIXIN
// wx.showShareMenu({
// withShareTicket: true,
// menus: ['shareAppMessage', 'shareTimeline']
// });
// //#endif
// },
// }
export default {
data() {
return {
......
import AlmostLottery from '@/uni_modules/almost-lottery/components/almost-lottery/almost-lottery.vue';
export default {
data() {
return {
loading: true,
// 以下是转盘配置相关数据
lotteryConfig: {
// 抽奖转盘的整体尺寸,单位rpx
lotterySize: 700,
// 抽奖按钮的尺寸,单位rpx
action: {
width: 188,
height: 228,
top: 228 - 188,
padding: 85
},
imgCircled: false,
},
// 转盘外环图,如有需要,请参考替换为自己的设计稿
lotteryBg: require('@/static/turn/zp.png'),
// // 抽奖按钮图
actionBg: require('@/static/turn/point.png'),
// 以下是奖品配置数据
// 奖品数据
prizeList: [
],
// 中奖下标
prizeIndex: -1,
// 是否正在抽奖中,避免重复触发
prizeing: false,
}
},
components: {
AlmostLottery
},
methods:{
remoteGetPrizeIndex(prizeId) {
let list = [...this.prizeList]
// 拿到后端返回的 prizeId 后,开始循环比对得出那个中奖的数据
for (let i = 0; i < list.length; i++) {
let item = list[i]
if (item.prizeId === prizeId) {
this.prizeIndex = i
break
}
}
console.log('本次抽中奖品 =>', this.prizeList[this.prizeIndex].prizeName)
// 如果奖品设有库存
},
// 抽奖转盘绘制完成
handleDrawFinish(res) {
console.log('抽奖转盘绘制完成', res)
}
}
}
import {
message,
loading,
redirectTo
} from "@/utils/fun.js"
const app = getApp();
export default {
data() {
return {
url: '',
imgList: [],
tempList: [],
current: 0,
count: 0,
leftHeight: 0,
rightHeight: 0,
};
},
methods: {
getData(page, size) {
return {
page,
size
}
},
loadData() {
if (!app.globalData.userInfo) {
// redirectTo('user/login');
return;
}
},
queryList(page, size) {
if (!app.globalData.userInfo) {
this.$refs.paging.complete([]);
return;
}
this.tempList = [];
this.current = 0;
if (page === 1) {
this.leftHeight = 0;
this.rightHeight = 0;
}
loading.show();
this.post({
url: this.url,
data: this.getData(page, size),
auth: true,
showLoading: false,
success: ({
data
}) => {
if (!data || !data.length) {
loading.hide();
this.$refs.paging.complete([]);
} else {
this.count = data.length;
this.imgList = data.map(item => {
item.url = `${item.url}?imageView2/2/w/250/interlace/1/q/99`;
return item;
});
this.loadImage();
}
},
fail: () => {
loading.hide();
}
});
},
loadImage() {
uni.getImageInfo({
src: this.imgList[this.current].url,
success: (image) => {
this.loadSuccess(image);
},
fail: () => {
this.imgList[this.current].url = this.imgList[this.current].url.replace(/\?imageView2.+/g, '');
uni.getImageInfo({
src: this.imgList[this.current].url,
success: (image) => {
this.loadSuccess(image);
}
})
}
})
},
loadSuccess(image) {
if (this.leftHeight <= this.rightHeight) {
this.imgList[this.current]['location'] = 'left';
this.leftHeight = this.leftHeight + image.height;
} else {
this.imgList[this.current]['location'] = 'right';
this.rightHeight = this.rightHeight + image.height;
}
this.current++;
if (this.current >= this.count) {
loading.hide();
this.$refs.paging.complete(this.imgList);
} else {
this.loadImage();
}
}
// loadImage({
// detail
// }, index, item) {
// item['index'] = index;
// item['height'] = 100 / detail.width * detail.height;
// console.log(detail.width, detail.height)
// this.tempList.push(Object.assign({}, item));
// if (this.tempList.length === this.count) {
// this.tempList = this.tempList.sort((a, b) => {
// return a.index - b.index
// })
// this.tempList = this.tempList.map(item => {
// if (this.leftHeight <= this.rightHeight) {
// item['location'] = 'left';
// item['leftHeight'] = this.leftHeight;
// this.leftHeight = this.leftHeight + item.height;
// } else {
// item['location'] = 'right';
// item['rightHeight'] = this.rightHeight;
// this.rightHeight = this.rightHeight + item.height;
// }
// return item;
// });
// loading.hide();
// this.imgList = [];
// this.$refs.paging.complete(this.tempList);
// }
// }
}
};
This diff is collapsed.
{
"uni-app": {
"scripts": {
"mp-dingtalk": {
"title": "钉钉小程序",
"env": {
"UNI_PLATFORM": "mp-alipay"
},
"define": {
"MP-DINGTALK": true
}
},
"mp-weixin-test": {
"title": "本地测试版本",
"env": {
"UNI_PLATFORM": "mp-weixin"
},
"define": {
"MP-APP-TEST": true
}
},
"mp-app-test": {
"title": "App 本地测试版本",
"env": {
"UNI_PLATFORM": "mp-weixin"
},
"define": {
"MP-APP-TEST": true
}
}
"dev": "cross-env NODE_ENV=development uniapp-cli build --watch",
"build:prod": "cross-env NODE_ENV=production uniapp-cli build"
}
},
"dependencies": {
"@pdf-lib/fontkit": "^1.1.1",
"pdf-lib": "^1.17.1",
"cropperjs": "^1.6.2",
"crypto-js": "^4.2.0",
"js-base64": "^3.7.7",
"js-md5": "^0.8.3",
"uview": "^0.1.0"
}
}
\ No newline at end of file
......@@ -20,14 +20,15 @@
"style": {
"navigationStyle": "default",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "#000000"
"navigationBarTextStyle": "black"
}
}, {
"path": "pages/brower/brower",
},
{
"path": "pages/login/login",
"style": {
"navigationStyle": "default",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
"navigationBarBackgroundColor": "#000000",
"navigationBarTextStyle": "white"
}
}
],
......@@ -52,105 +53,33 @@
}
}]
}, {
"root": "pagesC",
"root": "pagesB",
"pages": [{
"path": "scan/scan",
"style": {
"navigationBarTitleText": "扫描",
"navigationStyle": "default",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
}, {
"path": "edit/edit",
"path": "auth/auth",
"style": {
"navigationBarTitleText": "编辑",
"navigationStyle": "default",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
"navigationBarTitleText": "真人认证",
"navigationBarBackgroundColor": "#000000",
"navigationBarTextStyle": "white"
}
}, {
"path": "result/result",
"style": {
"navigationBarTitleText": "识别结果",
"navigationStyle": "default",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "measure/measure",
"style": {
"navigationBarTitleText": "AR测量",
"navigationStyle": "default",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "measureinfo/measureinfo",
"style": {
"navigationBarTitleText": "测量介绍",
"navigationStyle": "default",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "measurescan/measurescan",
"path": "label/label",
"style": {
"navigationBarTitleText": "测量拍摄",
"navigationStyle": "default",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "measureresult/measureresult",
"style": {
"navigationBarTitleText": "测量拍摄",
"navigationStyle": "default",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "superresult/superresult",
"style": {
"navigationBarTitleText": "万能识别结果",
"navigationStyle": "default",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
},
{
"path": "transresult/transresult",
"style": {
"navigationBarTitleText": "翻译结果",
"navigationStyle": "default",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
},
{
"path": "excelocr/excelocr",
"style": {
"navigationBarTitleText": "表格识别",
"navigationStyle": "default",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
"navigationBarTitleText": "个性标签",
"navigationBarBackgroundColor": "#000000",
"navigationBarTextStyle": "white",
"app-plus": {
"titleNView": {
"buttons": [{
"text": "确定",
"color": "#E9D07E",
"fontSize": "14px"
}]
}
},
{
"path": "excelresult/excelresult",
"style": {
"navigationBarTitleText": "识别结果",
"navigationStyle": "default",
"navigationBarBackgroundColor": "#2196f3",
"navigationBarTextStyle": "black"
}
}
]
}]
}, {
"root": "pagesD",
"pages": [{
......@@ -264,7 +193,7 @@
// 当我们进入了pages/home页面以后就会预下载pagesA分包
"pages/home": {
"network": "all", //在指定网络下预下载,可选值为:all(不限网络)、wifi(仅wifi下预下载)
"packages": ["pagesA", "pagesC", "pagesD"] //进入页面后预下载分包
"packages": ["pagesA", "pagesB", "pagesD"] //进入页面后预下载分包
}
},
"globalStyle": {
......
<template>
<view class="container">
<view class="title">短信验证码登录/注册</view>
<view class="input-group">
<input class="input" type="number" placeholder="+86 输入手机号" v-model="phoneNumber" />
</view>
<view class="input-group">
<input class="input" type="number" placeholder="输入验证码" v-model="verificationCode" />
<view class="get-code-btn" @click="getVerificationCode">获取验证码</view>
</view>
<button class="login-btn" @click="login">登录</button>
<view class="agreement">
<checkbox-group @change="agreeToTerms">
<label>
<checkbox value="agree" /> 已阅读并同意用户协议和隐私政策
</label>
</checkbox-group>
</view>
</view>
</template>
<script>
import {
mobileLogin,
sendMobileCode
} from '@/common/api/user.js'
import {
redirectTo,
message,
} from '@/utils/fun.js';
const app = getApp();
export default {
name: 'index',
data() {
return {
phoneNumber: '',
verificationCode: '',
agreed: false
};
},
methods: {
getVerificationCode() {},
login() {},
switchToPasswordLogin() {},
agreeToTerms(e) {
this.agreed = e.detail.value.includes('agree');
}
}
};
</script>
<style scoped>
.container {
height: 100vh;
background-color: black;
padding: 20rpx;
display: flex;
flex-direction: column;
}
.title {
margin-top: 150rpx;
font-size: 40rpx;
margin-bottom: 20rpx;
color: white;
}
.input-group {
position: relative;
margin-top: 50rpx;
}
.input {
width: 90%;
color: white;
border-bottom: solid 1rpx #555555;
background-color: transparent;
height: 80rpx;
padding: 15rpx;
}
.get-code-btn {
right: 10%;
top: 40rpx;
position: absolute;
color: white;
}
.login-btn {
width: 90%;
background-color: #E8CF83;
color: black;
border: none;
margin-top: 100rpx;
border-radius: 50rpx;
}
.switch-login {
text-align: center;
margin-bottom: 15rpx;
}
.agreement {
margin-top: 100rpx;
color: white;
text-align: center;
}
</style>
\ No newline at end of file
This diff is collapsed.
<template>
<view class="body">
<view class="header">
<text>已选择</text>
<text class="header-select">{{ selectedTags.length }}/{{maxSelectLimit}}</text>
</view>
<view class="tabs-section" v-if="isLike">
<view class="all-tags-container">
<view v-for="(tag, index) in likeTags" :key="index" :class="!tag.s?'tag':'tag_s'"
@click="toggleTag(tag)">
<text>{{ tag.name }}</text>
</view>
</view>
</view>
<view v-else>
<view class="tabs-section">
<text class="margin-b20">日常</text>
<view class="all-tags-container">
<view v-for="(tag, index) in usualTags" :key="index" :class="!tag.s?'tag':'tag_s'"
@click="toggleTag(tag)">
<text>{{ tag.name }}</text>
</view>
</view>
</view>
<view class="tabs-section">
<text class="margin-b20">特质</text>
<view class="all-tags-container">
<view v-for="(tag, index) in specialTags" :key="index" :class="!tag.s?'tag':'tag_s'"
@click="toggleTag(tag)">
<text>{{ tag.name }}</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import common from '@/mixins/common';
import {
UserProfile
} from '@/common/constant/userProfile.js';
import {
message,
loading
} from '@/utils/fun.js';
const app = getApp();
export default {
name: 'index',
mixins: [common],
data() {
return {
maxSelectLimit: 6,
selectedTags: [],
usualTags: [],
specialTags: [],
likeTags: [],
isLike: false
};
},
onLoad(option) {
this.isLike = option.like
this.initData()
},
onNavigationBarButtonTap() {
this.goBack()
},
onShow() {
this.selectedTags = []
},
methods: {
goBack() {
const data = {
message: this.selectedTags
};
let pages = getCurrentPages(); //获取所有页面栈实例列表
let nowPage = pages[pages.length - 1]; //当前页页面实例
let prevPage = pages[pages.length - 2]; //上一页页面实例
prevPage.$vm.trace_source = data //修改上一页data里面的地址
uni.navigateBack({})
},
initData() {
if (!this.isLike) {
// 男性
this.usualTags = UserProfile.USUAL_LABEL_MALE.arr
this.specialTags = UserProfile.SPECIAL_LABEL_MALE.arr
// 女性
this.usualTags = UserProfile.USUAL_LABEL_FEMALE.arr
this.specialTags = UserProfile.SPECIAL_LABEL_FEMALE.arr
} else {
this.likeTags = UserProfile.SPECIAL_LIKE_FEMALE.arr
}
},
toggleTag(tag) {
const index = this.selectedTags.indexOf(tag);
if (index === -1) {
if (this.selectedTags.length < 6) {
tag.s = true
this.selectedTags.push(tag);
}
} else {
tag.s = false
this.selectedTags.splice(index, 1);
}
}
}
};
</script>
<style lang="scss">
.body {
background-color: black;
padding-left: 30rpx;
padding-right: 30rpx;
padding-top: 150rpx;
}
.header {
font-size: 36rpx;
margin-bottom: 20rpx;
color: white;
}
.header-select {
font-size: 36rpx;
margin-left: 10rpx;
color: #E8CF83;
}
.tabs-section {
display: flex;
flex-direction: column;
color: white;
margin-top: 50rpx;
}
.all-tags-container {
display: flex;
flex-wrap: wrap;
}
.tag {
padding: 10rpx 20rpx;
margin: 10rpx;
color: #9C9AA5;
background-color: #272530;
border-radius: 50rpx;
cursor: pointer;
}
.tag_s {
padding: 10rpx 20rpx;
margin: 10rpx;
color: #0B0907;
background-color: #E9D07E;
border-radius: 50rpx;
cursor: pointer;
}
.tag text {
font-size: 26rpx;
}
</style>
\ No newline at end of file
<template>
<view class="wrapper">
<view class="show-img">
<image style="width: 80%;height: 90%;" :src="imgUri" mode="widthFix"></image>
</view>
<view class="item-bottom">
<view class="item-bottom-content" @click="crop">
<image class="img" src="../../static/ic_copy.png"></image>
<text class="text1">裁剪</text>
</view>
<view class="item-bottom-content" @click="clickOcr">
<image class="img2" src="../../static/ic_scan_ocr.png"></image>
<text class="text1">识别</text>
</view>
</view>
<l-clipper v-if="showlip" :image-url="tempUri" :isShowPhotoBtn="false" type="2d" :minWidth="400" :maxHeight="400"
@success="clipperSuc" @cancel="showlip = false" />
</view>
</template>
<script>
import {
pdfFn
} from '../../utils/pdf.js'
import {
navigateBack
} from '@/utils/fun';
import common from '@/mixins/common';
import {
ScanIndexBean,
ScanTypeBean
} from '@/utils/constant.js'
const app = getApp();
import {
navigateTo,
message,
redirectTo
} from '@/utils/fun';
export default {
name: 'edit',
mixins: [common],
data() {
return {
imgUri: '',
tempUri: '',
tempPath: '',
userBean: {},
type: '',
ocrUrl: '',
scantype: '',
showlip: false
};
},
onLoad(option) {
this.tempUri = decodeURIComponent(option.uri)
this.type = option.type
if (this.type == 0) {
// 万能识别
this.scantype = ScanTypeBean.advanced_general
} else if (option.type == 1) {
// 身份证
// this.scantype = ScanTypeBean.idcard_front
this.scantype = decodeURIComponent(option.cardType)
} else if (option.type == 2) {
// 拍照翻译
this.scantype = ScanTypeBean.fanyi
} else if (option.type == 3) {
// 文字识别
this.scantype = ScanTypeBean.accurate_basic
} else if (option.type == 4) {
// 文件识别
this.scantype = ScanTypeBean.accurate_basic
} else if (option.type == 5) {
// 表格识别
this.scantype = ScanTypeBean.img_to_excel
} else if (option.type == 6) {
// 图片转pdf
this.scantype = ScanTypeBean.scan_pdf
}
},
onShow() {
this.post({
url: '/user/baseMsg',
showLoading: false,
success: ({
data
}) => {
this.userBean = data;
}
});
},
methods: {
loadData() {
setTimeout(() => {
this.compress();
}, 200);
},
crop() {
this.showlip = true
},
compress() {
uni.showLoading({
title: '加载中...'
})
let that = this
// #ifdef MP-TOUTIAO
tt.compressImage({
src: that.tempUri,
quality: 80,
success: res => {
console.log('compressImage22223333',res)
that.uploadImg(res.tempFilePath)
},
fail: err => {
that.uploadImg(that.tempUri)
}
})
// #endif
},
clickOcr() {
if (this.userBean.expireTime <= 0) {
// 开通VIP会员
navigateTo(`/pagesA/vipPay/vipPay`)
} else {
this.ocr(this.ocrUrl)
}
},
clipperSuc(event){
this.tempUri = event.url;
this.showlip = false;
this.compress();
},
ocr(imgUrl) {
if (this.scantype == ScanTypeBean.scan_pdf) {
this.generatePDF([this.tempPath])
}else if (this.scantype == ScanTypeBean.fanyi) {
this.fanyi(ScanTypeBean.zh, ScanTypeBean.en, imgUrl)
} else if (this.scantype == ScanTypeBean.fanyi) {
this.fanyi(ScanTypeBean.en, ScanTypeBean.zh, imgUrl)
} else {
this.dealImage(imgUrl)
}
},
fanyi(from, to, imgUrl) {
let that = this;
this.post({
url: '/ai/fanyi',
data: {
from: from,
to: to,
imgUrl: imgUrl
},
showLoading: true,
success: ({
data
}) => {
that.goResult(data, imgUrl);
},
fail: () => {
setTimeout(() => {
message.notify('图片异常,请重新上传');
setTimeout(() => {
navigateBack();
}, 500);
}, 1000);
uni.hideLoading()
}
});
},
dealImage(myimgUrl) {
let that = this;
this.post({
url: '/ai/dealImage',
data: {
type: that.scantype,
imgUrl: myimgUrl
},
showLoading: true,
success: ({
data
}) => {
that.goResult(data, myimgUrl);
},
fail: () => {
uni.hideLoading()
setTimeout(() => {
message.notify('图片异常,请重新上传');
setTimeout(() => {
navigateBack();
}, 500);
}, 1000);
}
});
},
uploadImg(tempFilePath) {
this.tempPath=tempFilePath
let that = this;
let tempUrl = '/ai/image/upload';
tt.uploadFile({
url: `${app.globalData.baseUrl}${tempUrl}`,
filePath: tempFilePath,
header: {
'content-type': 'multipart/form-data',
pkgname: app.globalData.pkgName,
token: tt.getStorageSync('token')
},
name: 'file',
formData: {
"type": this.scantype
},
success: (uploadFileRes) => {
let myData = JSON.parse(uploadFileRes.data)
that.ocrUrl = myData.data.url
that.dyLink(that.ocrUrl)
},
fail: (res) => {
uni.hideLoading()
}
});
},
dyLink(url) {
let that = this;
this.post({
url: '/ai/image/dyLink',
data: {
imgUrl: url
},
showLoading: true,
success: ({
data
}) => {
that.imgUri = that.tempUri
if (that.scantype == ScanTypeBean.scan_pdf) {
if (that.userBean.expireTime <= 0) {
// 开通VIP会员
navigateTo(`/pagesA/vipPay/vipPay`)
return
}
that.generatePDF([that.tempPath])
}
},
fail: () => {
uni.hideLoading()
setTimeout(() => {
message.notify('图片存在风险,请重新上传');
setTimeout(() => {
navigateBack();
}, 500);
}, 1000);
}
});
},
goResult(data, imgUrl) {
uni.hideLoading()
if (this.type == 0) {
redirectTo(`/pagesC/superresult/superresult`, {
result: data.wiki.name,
wiki: data.wiki.baikeDescription,
imgUrl: data.innerUrl
})
} else if (this.type == 2) {
redirectTo(`/pagesC/transresult/transresult`, {
imgUrl: imgUrl,
from: data.from,
to: data.to
})
} else if (this.type == 1) {
var text = ''
if (data.cardList != null && data.cardList.length > 0) {
let list = data.cardList;
for (let i in list) {
for (let key in list[i]) {
text += "\n" + key + ":" + list[i][key]
}
}
}
redirectTo(`/pagesC/result/result`, {
imgUrl: imgUrl,
result: text,
type: this.type
})
} else if (this.type == 5) {
redirectTo(`/pagesC/excelocr/excelocr`, {
imgUrl: imgUrl,
task_id: data.results.task_id
})
} else {
redirectTo(`/pagesC/result/result`, {
imgUrl: imgUrl,
result: data.fontText,
type: this.type
})
}
},
generatePDF(imageUrls) {
let that = this
pdfFn(imageUrls, 2).then((resl) => {
var fs = tt.getFileSystemManager();
console.log("123==", imageUrls)
fs.writeFile({
filePath: tt.env.USER_DATA_PATH + '/' + that.getCurrentTime() + '.pdf',
data: resl.docBase64,
encoding: "base64",
success: resx => {
tt.openDocument({
filePath: tt.env.USER_DATA_PATH + '/' + that.getCurrentTime() +
'.pdf',
showMenu: true,
success: function(resxl) {
uni.hideLoading()
console.log(resxl);
},
fail(err) {
uni.hideLoading()
console.log(err);
}
})
}
})
})
},
getCurrentTime() {
const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
}
}
</script>
<style lang="scss">
.wrapper {
display: flex;
flex-direction: column;
height: 100%;
}
.show-img {
flex: 1;
background-color: #f0f8ff;
display: flex;
justify-content: center;
align-items: center;
}
.item-bottom {
background-color: #ffffff;
height: 165rpx;
padding-bottom: 15rpx;
display: flex;
flex-direction: row;
}
.item-bottom-content {
display: flex;
flex-direction: column;
flex: 1;
align-items: center;
.img {
margin-top: 30rpx;
width: 50rpx;
height: 50rpx;
}
.img2 {
margin-top: 30rpx;
width: 50rpx;
height: 50rpx;
}
.text1 {
margin-top: 6rpx;
color: #000000;
}
}
</style>
\ No newline at end of file
<template>
<view class="body">
<view style="display: flex;flex-direction: column;height: 100%;">
<view style="height: 60%;text-align: center;">
<image mode="heightFix" class="mt-30" style="width: 500rpx;"
src="https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg/img/ic_share_right.png" />
</view>
<view class="flex1" style="height: 40%;padding: 30rpx 50rpx;">
<view style="font-weight: bold;font-size: 40rpx;margin-top: 50rpx;">正在识别文件</view>
<view style="font-size: 36rpx;margin-top: 50rpx;">请耐心等候</view>
<progress class="mt-30" activeColor="#008cfb" :percent="100-totalSeconds" stroke-width="10" />
</view>
</view>
</view>
</template>
<script>
import common from '@/mixins/common';
import {
redirectTo,
navigateBack
} from '@/utils/fun';
const app = getApp();
export default {
name: 'ocr',
mixins: [common],
data() {
return {
imgUrl: '',
task_id: '',
timer: null, // 计时器
totalSeconds: 80, // 计时器
};
},
onLoad(option) {
this.task_id = decodeURIComponent(option.task_id)
this.imgUrl = decodeURIComponent(option.imgUrl)
},
onUnload() {
this.clearCountdown(); // 清除计时器
},
created() {
this.startCountdown(); // 开始倒计时
this.queryExcel()
},
methods: {
queryExcel() {
let that = this
this.post({
url: '/ai/queryExcel',
showLoading: false,
data: {
task_id: that.task_id,
},
success: ({
data
}) => {
if (data.code == 1) {
if (data.excel == '' && data.word == '') {
that.ocrFail()
return
}
that.clearCountdown()
redirectTo(`/pagesC/excelresult/excelresult`, {
imgUrl: that.imgUrl,
word: data.word,
excel: data.excel
})
}
},
fail: () => {
that.clearCountdown()
that.ocrFail()
}
});
},
// 开始倒计时
startCountdown() {
this.timer = setInterval(() => {
if (this.totalSeconds > 0) {
if (this.totalSeconds % 5 == 0) {
this.queryExcel()
}
this.totalSeconds -= 1;
} else {
this.clearCountdown();
this.ocrFail()
}
}, 1000);
},
// 清除倒计时
clearCountdown() {
clearInterval(this.timer);
this.timer = null;
},
ocrFail() {
uni.showModal({
title: '提示',
content: '表格识别失败',
showCancel: false,
confirmColor: '#008cfb',
success: function(res) {
navigateBack()
}
});
}
},
}
</script>
<style lang="scss">
</style>
\ No newline at end of file
<template>
<view class="body">
<view style="display: flex;flex-direction: column;height: 100%;">
<view style="height: 40%; display: flex;justify-content: center;align-items: center;">
<image mode="heightFix" :src="imgUrl" />
</view>
<view style="background: white;height: 50%;text-align: center;">
<image mode="heightFix" class="mt-20"
src="https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg/img/ic_share_right.png" />
</view>
<view style="height: 10%;display: flex;flex-direction: row;background: white;">
<view @click="close"
style="display: flex;flex-direction: column;flex: 1;align-items: center;padding-top: 20rpx;">
<image style="width: 30rpx;height: 30rpx;" src="../../static/ic_copy.png">
</image>
<view style="font-size: 30rpx;">返回</view>
</view>
<button @click="downloadFile"
style="display: flex;flex-direction: column;flex: 1;align-items: center;padding-top: 20rpx;">
<image style="width: 30rpx;height: 30rpx;" src="../../static/ic_copy.png">
</image>
<view style="font-size: 30rpx;">打开文件</view>
</button>
</view>
</view>
</view>
</template>
<script>
import {
navigateBack
} from '../../utils/fun';
import common from '@/mixins/common';
const app = getApp();
export default {
name: 'excelresult',
mixins: [common],
data() {
return {
word: '',
excel: '',
imgUrl: '',
};
},
onLoad(option) {
this.imgUrl = decodeURIComponent(option.imgUrl)
this.word = decodeURIComponent(option.word)
this.excel = decodeURIComponent(option.excel)
},
methods: {
downloadFile() {
uni.showLoading({
title: '加载中...'
})
var downloadUrl = this.word
if (downloadUrl == "") {
downloadUrl = this.excel
}
let that = this
uni.downloadFile({
url: downloadUrl, //仅为示例,并非真实的资源
success: (res) => {
uni.hideLoading()
if (res.statusCode === 200) {
that.open(res.tempFilePath)
}
},
fail: (error) => {
uni.hideLoading()
console.log(error)
}
});
},
close() {
navigateBack()
},
open(filePath) {
tt.openDocument({
filePath: filePath,
showMenu: true,
success: function(resxl) {
uni.hideLoading()
console.log(resxl);
},
fail(err) {
uni.hideLoading()
console.log(err);
}
})
}
},
}
</script>
<style lang="scss">
</style>
\ No newline at end of file
<template>
<view class="body">
<view class="flex" style="padding:10rpx;">
<image @click="handleMeasureLength" src="https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg/img/ic_ar_length.png">
</image>
<image @click="handleMeasureHeight" src="https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg/img/ic_ar_height.png">
</image>
</view>
</view>
</template>
<script>
import common from '@/mixins/common';
const app = getApp();
import {
navigateTo
} from '@/utils/fun';
export default {
name: 'measure',
mixins: [common],
data() {
return {
}
},
methods: {
handleMeasureLength() {
navigateTo(`/pagesC/measureinfo/measureinfo`, {
isMeasureHeight: 0
})
},
handleMeasureHeight() {
navigateTo(`/pagesC/measureinfo/measureinfo`, {
isMeasureHeight: 1
})
}
}
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<view class="body">
<scroll-view scroll-y style="width: 100%;overflow: hidden;white-space: nowrap;flex:1;padding-top: 10rpx;">
<image mode="widthFix" v-if="isMeasureHeight==0" src="https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg/img/bg_ar_height.png">
</image>
<image mode="widthFix" v-else src="https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg/img/bg_ar_length.png ">
</image>
</scroll-view>
<view class="button" style="margin-bottom: 50rpx;" @click="handleScan">开始测量</view>
</view>
</template>
<script>
import common from '@/mixins/common';
const app = getApp();
import {
navigateTo
} from '@/utils/fun';
export default {
name: 'measureinfo',
mixins: [common],
data() {
return {
isMeasureHeight: 0
}
},
onLoad(options) {
this.isMeasureHeight = options.isMeasureHeight
},
methods: {
handleScan() {
navigateTo(`/pagesC/measurescan/measurescan`, {
isMeasureHeight: this.isMeasureHeight
})
}
}
}
</script>
<style lang="scss">
.scroll-view {
flex: 1;
overflow: hidden;
height: 90%;
}
</style>
\ No newline at end of file
<template>
<view class="body">
<view class="flex1" style="border-radius: 30rpx;background-color: #DAE6FB;color: black;width: 85%;margin: 0 auto;
padding: 15rpx 20rpx;margin-top: 20rpx;">
<view class="flex" style="height: 80rpx;justify-content: center;">
<view style="color: #187CFB;flex:1;">测量结果</view>
<view>{{distance}}cm</view>
</view>
<view class="flex" style="height: 80rpx;justify-content: center;">
<view style="flex:1;">您的身高</view>
<view>{{height}}cm</view>
</view>
<view class="flex" style="height: 80rpx;justify-content: center;">
<view style="flex:1;">俯视角度</view>
<view>{{angle}}°</view>
</view>
<view v-if="isMeasureHeight==1" class="flex" style="height: 80rpx;justify-content: center;">
<view style="flex:1;">仰角角度</view>
<view>{{angle2}}°</view>
</view>
</view>
</view>
</template>
<script>
import common from '@/mixins/common';
const app = getApp();
import {
navigateTo
} from '@/utils/fun';
export default {
name: 'measureresult',
mixins: [common],
data() {
return {
isMeasureHeight: 0,
height: '',
angle: '',
angle2: '',
distance: '',
}
},
onLoad(options) {
this.isMeasureHeight = options.isMeasureHeight
this.height = options.height
this.angle = options.angle
this.angle2 = options.angle2
this.distance = Math.round(options.distance * 100) / 100
},
methods: {}
}
</script>
<style lang="scss">
</style>
\ No newline at end of file
<template>
<view class="body">
<view style="position:absolute;width:100%;height:100%;">
<camera v-if="showCamera" id="camera" resolution="high" device-position="back" flash="off" @error="error"
@initdone="initdone" style="width:100%;height:100%;">
</camera>
</view>
<image class="icon_center" mode="aspectFit" src="../../static/ic_center.png" />
<image class="icon_close" @click="close" mode="aspectFit" src="../../static/ic_close.png" />
<view class="text_position">
<view>靶心对准物体</view>
<view style="color: red;">{{scanPosition}}</view>
<view>后点击拍照</view>
</view>
<image v-if="isMeasureHeight==1 && isClickTwo" class="icon_back" @click="takeBack" mode="aspectFit"
src="../../static/ic_back.png" />
<image class="icon_take" @click="takePhoto" mode="aspectFit" src="../../static/ic_take_photo.png" />
<uni-data-picker class="picker" placeholder="请选择身高" :localdata="items" popup-title="请选择身高"
@nodeclick="onnodeclick" :clear-icon="false">
<view class="pickerveiw">
<image style="width: 40rpx;height: 40rpx;" src="/static/ic_edit_blue.png"></image>
<text style="color: #187CFB;font-size: 30rpx;margin-left: 15rpx;">{{mHeight}}cm</text>
</view>
</uni-data-picker>
</view>
</template>
<script>
import common from '@/mixins/common';
import {
imageCompress
} from "@/utils/utils.js"
import {
openSetting,
} from '@/utils/utils.js';
import {
redirectTo,
navigateTo,
navigateBack
} from '@/utils/fun';
const app = getApp();
export default {
name: 'measurescan',
mixins: [common],
data() {
return {
isMeasureHeight: 0,
mHeight: 170,
scanPosition: '底部',
isClickTwo: false,
items: [],
showPicker: false,
userBean: {},
showCamera: true
}
},
onLoad(options) {
var minHeight = 100
for (let i = 12; i > 0; i--) {
this.items.unshift({
text: (minHeight += 10),
value: '身高' + minHeight
})
}
this.isMeasureHeight = options.isMeasureHeight
},
onShow() {
this.post({
url: '/user/baseMsg',
showLoading: false,
success: ({
data
}) => {
this.userBean = data;
}
});
this.showCamera = true
},
methods: {
takePhoto() {
if (!this.showCamera) {
this.showCamera = true
}
if (this.isMeasureHeight == 1 && !this.isClickTwo) {
this.isClickTwo = true
this.scanPosition = "顶部"
return
}
if (this.userBean.expireTime <= 0) {
// 开通VIP会员
navigateTo(`/pagesA/vipPay/vipPay`)
} else {
this.toResult()
}
},
error(e) {
console.log(e.detail);
if (e.errNo == 10200) {
this.showCamera = false
this.goAuthSetting()
}
},
goAuthSetting() {
tt.showModal({
title: `获取权限失败`,
content: `未授权,请在设置页授权`,
success(res) {
if (res.confirm) {
openSetting()
} else if (res.cancel) {
uni.showToast({
title: '取消授权'
})
}
},
});
},
initdone({
detail: {
maxZoom
}
}) {
// 最大放大倍速
this.maxZoom = maxZoom / 2
},
close() {
navigateBack();
},
toResult() {
var angle = Math.floor(Math.random() * 180) + 1;
var angle2 = Math.floor(Math.random() * 180) + 1;
var distance = Math.abs(this.mHeight * Math.tan(angle * Math.PI / 180))
redirectTo(`/pagesC/measureresult/measureresult`, {
isMeasureHeight: this.isMeasureHeight,
height: this.mHeight,
angle: angle,
angle2: angle2,
distance: distance
})
},
onnodeclick(res) {
this.mHeight = parseInt(res.text)
},
takeBack() {
this.isClickTwo = false
this.scanPosition = "低部"
}
}
}
</script>
<style lang="scss">
.body {
background: black;
position: relative;
}
.icon_close {
position: absolute;
width: 80rpx;
height: 80rpx;
left: 30rpx;
top: 30rpx;
}
.icon_take {
position: absolute;
width: 120rpx;
height: 120rpx;
left: 50%;
bottom: 150rpx;
margin-left: -50rpx;
}
.icon_back {
position: absolute;
width: 80rpx;
height: 80rpx;
left: 20%;
bottom: 170rpx;
}
.text_position {
position: absolute;
width: 100%;
left: 50%;
bottom: 300rpx;
margin-left: -50%;
color: white;
display: flex;
flex-direction: row;
justify-content: center;
}
.icon_center {
position: absolute;
width: 150rpx;
height: 150rpx;
left: 50%;
top: 50%;
margin-top: -75rpx;
margin-left: -75rpx;
}
.picker {
position: absolute;
top: 30rpx;
right: 30rpx;
border-radius: 10rpx;
background-color: transparent;
}
.pickerveiw {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
padding: 10rpx 20rpx;
background: rgba(255, 255, 255, 0.8);
border-radius: 20rpx;
}
</style>
\ No newline at end of file
<template>
<view class="body">
<!-- <status-title :showBack="true" iconColor="black">识别结果</status-title> -->
<view style="display: flex;flex-direction: column;height: 100%;">
<view style="height: 40%; display: flex;justify-content: center;align-items: center;">
<image mode="heightFix" :src="imgUrl" />
</view>
<view style="background: white;height: 50%;display: flex;flex-direction: column;padding: 30rpx 20rpx;">
<view style="font-weight: bold;padding-left: 10rpx;font-size: 40rpx;">识别结果</view>
<scroll-view :scroll-y="true" style="overflow: hidden;white-space: nowrap;flex:1;">
<view v-if="type==3 || type == 1 || type == 4">
<block v-for="(item, index) in dataList" :key="index">
<view>
<view style="margin: 10rpx;font-size: 30rpx;">{{item}}</view>
<view style="height: 1rpx;width: 100%;background: darkgray;"
v-if="index<dataList.length-1"></view>
</view>
</block>
</view>
</scroll-view>
</view>
<view style="height: 10%;display: flex;flex-direction: row;background: white;">
<view @click="copy"
style="display: flex;flex-direction: column;flex: 1;align-items: center;padding-top: 20rpx;">
<image style="width: 30rpx;height: 30rpx;" src="../../static/ic_copy.png">
</image>
<view style="font-size: 30rpx;">复制</view>
</view>
<button open-type="share"
style="display: flex;flex-direction: column;flex: 1;align-items: center;padding-top: 20rpx;">
<image style="width: 30rpx;height: 30rpx;" src="../../static/ic_copy.png">
</image>
<view style="font-size: 30rpx;">导出</view>
</button>
</view>
</view>
</view>
</template>
<script>
import common from '@/mixins/common';
const app = getApp();
export default {
name: 'result',
mixins: [common],
data() {
return {
result: '',
imgUrl: '',
dataList: [],
type: 0
};
},
onLoad(option) {
this.type = option.type
this.result = decodeURIComponent(option.result)
this.imgUrl = decodeURIComponent(option.imgUrl)
this.dataList = this.result.split('\n')
},
onShareAppMessage() {
return {
title: '智能扫描精灵',
summary: this.result,
success() {
console.log('分享成功');
},
fail(err) {
console.error('分享失败', err);
}
};
},
methods: {
copy() {
uni.setClipboardData({
data: this.result,
complete() {
uni.showToast({
title: "已复制到剪贴板"
})
}
})
}
},
}
</script>
<style lang="scss">
</style>
\ No newline at end of file
<template>
<view class="body">
<view style="position:relative;width:100%;height:70%;">
<camera v-if="showCamera" id="camera" resolution="high" device-position="back" flash="off" @error="error"
@initdone="initdone" style="width:100%;height:100%;">
</camera>
</view>
<view class="hint" v-if="current==0">请保持水平清晰</view>
<view class="card" v-if="current==1" @click="showPop">
<text>{{currentCard}}</text>
<image src="../../static/arrow_down.png" style="width: 30rpx;height: 30rpx;"></image>
</view>
<view style="display: flex;flex-direction: column;width:100%;height:30%;'">
<tabs-center2 class="center" :tabs="tabs" v-model="current" @change="handleChange" />
<view style="display: flex;">
<view class="icon_flex" @click="close">
<image mode="aspectFit" style="width: 80rpx;height: 80rpx;" src="../../static/ic_close.png" />
</view>
<view class="icon_flex" @click="takePhoto">
<image mode="aspectFit" src="../../static/ic_take_photo.png" />
</view>
<view class="icon_flex" @click="openAlbum">
<image mode="aspectFit" style="width: 80rpx;height: 80rpx;" src="../../static/ic_photo.png" />
</view>
</view>
</view>
<uni-popup ref="popup" type="bottom" borderRadius="20rpx 20rpx 0 0" background-color="#fff">
<view class="popup-content">
<text class="mt-20 margin-b10" style="font-weight: bold;">请选择证件类型</text>
<view style="width: 100%;height: 1rpx;background-color: royalblue;"></view>
<block v-for="(item, index) in list" :key="index">
<text class="mt-20" @click="change(index)">{{item}}</text>
</block>
</view>
</uni-popup>
</view>
</template>
<script>
import common from '@/mixins/common';
import {
ScanIndexBean,
ScanTypeBean
} from '@/utils/constant.js'
import {
imageCompress
} from "@/utils/utils.js"
import {
openSetting,
} from '@/utils/utils.js';
import {
navigateTo,
navigateBack,
reLaunch
} from '@/utils/fun';
const app = getApp();
export default {
name: 'scan',
mixins: [common],
data() {
return {
current: 0,
currentCard: '身份证正面',
tabs: [{
title: '万能识别',
value: 0
}, {
title: '证件识别',
value: 1
}, {
title: '拍照翻译',
value: 2
}, {
title: '文字识别',
value: 3
}, {
title: '文件扫描',
value: 4
}, {
title: '表格识别',
value: 5
}, {
title: '图片转PDF',
value: 6
}, ],
list: ['身份证正面', '身份证反面'],
cardType: ScanTypeBean.idcard_front,
showCamera: true
}
},
onLoad(option) {
this.current = option.type
},
onShow() {
this.showCamera = true
},
methods: {
takePhoto() {
if (!this.showCamera) {
this.showCamera = true
}
uni.showLoading({
title: '加载中...'
})
let that = this
// #ifdef MP-TOUTIAO
let cameraContext = tt.createCameraContext('camera');
cameraContext.takePhoto({
quality: 'high',
success(res) {
uni.hideLoading()
navigateTo(`/pagesC/edit/edit`, {
uri: res.tempImagePath,
type: that.current,
cardType: that.cardType
})
},
fail(err) {
uni.hideLoading()
console.log(err);
},
});
// #endif
},
openAlbum() {
let that = this
uni.chooseImage({
count: 1,
sizeType: ['compressed'],
sourceType: ["album"],
success: (res) => {
navigateTo(`/pagesC/edit/edit`, {
uri: res.tempFilePaths,
type: that.current,
cardType: that.cardType
})
},
fail: (res) => {
// 拒绝授权
if (res.errNo == 10200) {
setTimeout(() => {
that.goAuthSetting()
}, 500)
}
}
});
},
error(e) {
if (e.errNo == 10200) {
this.showCamera = false
this.goAuthSetting()
}
console.log(e.detail);
},
goAuthSetting() {
tt.showModal({
title: `获取权限失败`,
content: `未授权,请在设置页授权`,
success(res) {
if (res.confirm) {
openSetting()
} else if (res.cancel) {
uni.showToast({
title: '取消授权'
})
}
},
});
},
initdone({
detail: {
maxZoom
}
}) {
// 最大放大倍速
this.maxZoom = maxZoom / 2
},
close() {
navigateBack();
},
handleChange(res) {
this.current = res.value
if (!this.showCamera) {
this.showCamera = true
}
},
showPop() {
this.$refs.popup.open('bottom')
},
change(e) {
this.$refs.popup.close()
if (e == 0) {
this.cardType = ScanTypeBean.idcard_front
} else {
this.cardType = ScanTypeBean.idcard_back
}
this.currentCard = this.list[e]
}
}
}
</script>
<style lang="scss">
.body {
background: black;
}
.img {
width: 60rpx;
height: 60rpx;
}
.font {
text-align: center;
font-size: 30rpx;
color: white;
margin-top: 30rpx;
}
.font2 {
text-align: center;
font-size: 30rpx;
color: royalblue;
margin-top: 30rpx;
}
.icon_flex {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-top: 50rpx;
image {
width: 120rpx;
height: 120rpx;
}
}
.card {
padding-left: 20rpx;
padding-right: 20rpx;
color: white;
border-radius: 10rpx;
background-color: black;
position: absolute;
width: 180rpx;
height: 70rpx;
margin-left: -100rpx;
left: 50%;
top: 8%;
display: flex;
align-items: center;
justify-content: space-between;
}
.hint {
padding-left: 20rpx;
padding-right: 20rpx;
padding-top: 10rpx;
padding-bottom: 10rpx;
color: white;
border-radius: 10rpx;
background-color: black;
position: absolute;
left: 50%;
bottom: 30%;
transform: translate(-50%, -50%);
animation: fadeInOut 2s ease infinite;
}
.popup-content {
display: flex;
flex-direction: column;
// align-items: center;
// justify-content: center;
padding: 15px;
font-size: 36rpx;
background-color: #fff;
}
@keyframes fadeInOut {
0% {
opacity: 0.3;
}
50% {
opacity: 0.7;
}
100% {
opacity: 0.3;
}
}
</style>
\ No newline at end of file
<template>
<view class="body">
<view class="content flex-v">
<view class="flex">
<image style="height: 200rpx;margin-left: 30rpx;" mode="heightFix" :src="imgUrl"></image>
<view class="flex-v" style="margin-left: 30rpx;">
<text style="color: gray;font-size: 36rpx;">图中可能是</text>
<text style="color: black;font-size: 40rpx;max-width: 400rpx;margin-top: 20rpx;">{{result}}</text>
</view>
</view>
<view class="flex-v" style="margin-top: 80rpx;">
<view class="flex">
<text style="color: black;font-size: 40rpx;">百科</text>
<text style="color: gray;font-size: 30rpx;margin-left: 20rpx;">WIKIPEDIA</text>
</view>
<view style="height: 1rpx;background-color: gray;margin-top: 10rpx;"></view>
<text style="color: black;font-size: 36rpx;;margin-top: 30rpx;">{{wiki?wiki:'暂无百科介绍'}}</text>
</view>
</view>
<image class="img" src="https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg/img/ic_ai_result.png" mode="widthFix"></image>
</view>
</template>
<script>
import common from '@/mixins/common';
const app = getApp();
export default {
name: '百科结果',
mixins: [common],
data() {
return {
result: '',
wiki: '',
imgUrl: '',
};
},
onLoad(option) {
this.result = decodeURIComponent(option.result)
this.wiki = decodeURIComponent(option.wiki)
this.imgUrl = decodeURIComponent(option.imgUrl)
},
onShareAppMessage() {
return {
title: '智能扫描精灵',
summary: this.result,
success() {
console.log('分享成功');
},
fail(err) {
console.error('分享失败', err);
}
};
},
methods: {
copy() {
uni.setClipboardData({
data: this.result,
complete() {
uni.showToast({
title: "已复制到剪贴板"
})
}
})
}
},
}
</script>
<style lang="scss">
.body {
position: relative;
}
.content {
position: absolute;
width: 90%;
height: 80%;
top: 100rpx;
left: 5%;
background-color: white;
border-radius: 20rpx;
box-shadow: 0 0 4px darkgray;
padding: 80rpx 30rpx 0 30rpx;
}
.img {
position: absolute;
width: 294rpx;
height: 62rpx;
left: 50%;
margin-left: -146rpx;
top: 69rpx;
}
</style>
\ No newline at end of file
<template>
<view class="body">
<!-- <status-title :showBack="true" iconColor="black">识别结果</status-title> -->
<view style="display: flex;flex-direction: column;height: 100%;">
<view style="height: 40%; display: flex;justify-content: center;align-items: center;">
<image mode="heightFix" :src="imgUrl"></image>
</view>
<view style="background: white;height: 50%;display: flex;flex-direction: column;padding: 30rpx 20rpx;">
<view style="font-weight: bold;padding-left: 10rpx;font-size: 40rpx;">识别结果</view>
<scroll-view :scroll-x="true" style="overflow: hidden;white-space: nowrap;flex:1;width: 100%;">
<view style="padding: 10rpx;">{{from}}</view>
<view style="padding: 10rpx;">{{to}}</view>
</scroll-view>
</view>
<view style="height: 10%;display: flex;flex-direction: row;background: white;">
<view @click="copy"
style="display: flex;flex-direction: column;flex: 1;align-items: center;padding-top: 20rpx;">
<image style="width: 30rpx;height: 30rpx;" src="../../static/ic_copy.png">
</image>
<view style="font-size: 30rpx;">复制</view>
</view>
<button open-type="share"
style="display: flex;flex-direction: column;flex: 1;align-items: center;padding-top: 20rpx;">
<image style="width: 30rpx;height: 30rpx;" src="../../static/ic_copy.png">
</image>
<view style="font-size: 30rpx;">导出</view>
</button>
</view>
</view>
</view>
</template>
<script>
import common from '@/mixins/common';
const app = getApp();
export default {
name: 'transresult',
mixins: [common],
data() {
return {
imgUrl: '',
from: '',
to: '',
};
},
onLoad(option) {
this.from = decodeURIComponent(option.from)
this.to = decodeURIComponent(option.to)
this.imgUrl = decodeURIComponent(option.imgUrl)
},
onShareAppMessage() {
return {
title: '智能扫描精灵',
summary: this.result,
success() {
console.log('分享成功');
},
fail(err) {
console.error('分享失败', err);
}
};
},
methods: {
copy() {
uni.setClipboardData({
data: this.to,
complete() {
uni.showToast({
title: "已复制到剪贴板"
})
}
})
}
},
}
</script>
<style lang="scss">
</style>
\ No newline at end of file
## 9.1.2(2024-10-03)
组件优化
## 9.1.0(2024-07-14)
组件优化
## 9.1(2024-04-04)
修复组件存在的问题
## 9.0(2024-04-04)
有前端伙伴修复了组件存在的一些问题
## 8.0(2024-03-04)
优化组件代码
## 7.0(2023-12-28)
增加地址编码
## 6.0.1(2023-10-13)
适配vue3
## 6.0(2023-10-08)
修复vue3.0bug, 兼容vue2.0
## 5.0(2023-09-16)
1:增加初始省市区默认值设置 2:优化组件体验
## 4.0.1(2023-09-03)
优化了一些问题
## 4.0.0(2023-08-26)
更新中国最新省市区数据
## 3.0.2(2023-08-26)
修改区数据格式
## 3.0.1(2023-07-31)
修复vue3.0bug
## 3.0(2023-07-19)
组件优化
## 2.0.3(2023-07-19)
修复退出界面,省市区选项显示bug
## 2.0.2(2023-07-13)
更新无锡市信息
## 2.0.1(2023-07-11)
组件优化
## 2.0.0(2023-07-11)
修复vue3.0bug, 支持vue3.0
## 1.0.6(2023-06-29)
组件优化
## 1.0.4(2023-06-29)
组件优化
## 1.0.3(2023-06-29)
组件优化
## 1.0.2(2023-06-29)
组件说明优化
## 1.0.1(2023-06-29)
组件优化
## 1.0.0(2023-06-28)
组件初始化
<template>
<view>
<!--自定义地址选择器-->
<view class="cc_area_mask" v-show="show == true"></view>
<view :class="'cc_area_view ' + (show ? 'show':'hide')">
<view class="cc_area_view_btns">
<text class="cc_area_view_btn_cancle" @tap="handleNYZAreaCancle">取消</text>
<text class="cc_area_view_btn_title" style="color: #393939;font-size: 32upx;">地区选择</text>
<text class="cc_area_view_btn_sure" @tap="handleNYZAreaSelect" :data-province="province"
:data-city="city" :data-area="area" style="color: #4284e5;">确定</text>
</view>
<picker-view class="cc_area_pick_view" indicator-style="height: 35px;" @change="handleNYZAreaChange"
:value="value">
<picker-view-column>
<view v-for="(item, index) in provinces" :key="index" class="cc_area_colum_view">{{item}}</view>
</picker-view-column>
<picker-view-column>
<view v-for="(item, index) in citys" :key="index" class="cc_area_colum_view">{{item}}</view>
</picker-view-column>
<picker-view-column>
<view v-for="(item, index) in areas" :key="index" class="cc_area_colum_view">{{item}}</view>
</picker-view-column>
</picker-view>
</view>
</view>
</template>
<script>
import {
getProvinces,
getMyCity,
getAreas,
getAreasCode
} from "./area.js"
let index = [0, 0, 0];
let provinces = getProvinces();
let citys = getMyCity(index[0]);
let areas = getMyCity(index[0], index[1]);
export default {
mixins: [{
methods: {
setData: function(obj, callback) {
let that = this;
const handleData = (tepData, tepKey, afterKey) => {
tepKey = tepKey.split('.');
tepKey.forEach(item => {
if (tepData[item] === null || tepData[item] === undefined) {
let reg = /^[0-9]+$/;
tepData[item] = reg.test(afterKey) ? [] : {};
tepData = tepData[item];
} else {
tepData = tepData[item];
}
});
return tepData;
};
const isFn = function(value) {
return typeof value == 'function' || false;
};
Object.keys(obj).forEach(function(key) {
let val = obj[key];
key = key.replace(/\]/g, '').replace(/\[/g, '.');
let front, after;
let index_after = key.lastIndexOf('.');
if (index_after != -1) {
after = key.slice(index_after + 1);
front = handleData(that, key.slice(0, index_after), after);
} else {
after = key;
front = that;
}
if (front.$data && front.$data[after] === undefined) {
Object.defineProperty(front, after, {
get() {
return front.$data[after];
},
set(newValue) {
front.$data[after] = newValue;
that.$forceUpdate();
},
enumerable: true,
configurable: true
});
// #ifndef VUE3
that.$set(front, after, val);
// #endif
// #ifdef VUE3
Reflect.set(front, after, val);
// #endif
} else {
// #ifndef VUE3
that.$set(front, after, val);
// #endif
// #ifdef VUE3
Reflect.set(front, after, val);
// #endif
}
});
isFn(callback) && this.$nextTick(callback);
}
}
}],
data() {
return {
provinces: getProvinces(),
citys: getMyCity(index[0]),
areas: getAreas(index[0], index[1]),
value: [0, 0, 0]
};
},
components: {},
props: {
// 省
province: {
//控制area_select显示隐藏
type: String,
default: ''
},
// 市
city: {
//控制area_select显示隐藏
type: String,
default: ''
},
// 区
area: {
//控制area_select显示隐藏
type: String,
default: ''
},
show: {
//控制area_select显示隐藏
type: Boolean,
default: false
},
maskShow: {
//是否显示蒙层
type: Boolean,
default: true
}
},
watch: {
province() {
this.init();
},
city() {
this.init();
},
area() {
this.init();
}
},
mounted() {
let provinceIndex = this.provinces.indexOf(this.province);
this.citys = getMyCity(provinceIndex);
let cityIndex = this.citys.indexOf(this.city);
this.areas = getAreas(provinceIndex, cityIndex);
let areaIndex = this.areas.indexOf(this.area);
// 设置选择序列
this.value = [provinceIndex, cityIndex, areaIndex];
let areaCode = getAreasCode(provinceIndex, cityIndex, areaIndex);
//console.log(areaCode)
//console.log("this.value = " + JSON.stringify(this.value));
},
methods: {
init() {
//console.log(this.area)
let provinceIndex = this.provinces.indexOf(this.province);
this.citys = getMyCity(provinceIndex);
let cityIndex = this.citys.indexOf(this.city);
this.areas = getAreas(provinceIndex, cityIndex);
let areaIndex = this.areas.indexOf(this.area);
//获取地区编码
let areaCode = getAreasCode(provinceIndex, cityIndex, areaIndex);
// 设置选择序列
this.value = [provinceIndex, cityIndex, areaIndex];
},
handleNYZAreaChange: function(e) {
var that = this;
var value = e.detail.value;
// 更新 index
index = value;
// 获取对应的城市和区域数据
let selectCitys = getMyCity(index[0]);
let selectAreas = getAreas(index[0], index[1]);
// 触发 setData 更新数据
that.setData({
citys: selectCitys,
areas: selectAreas,
value: index
});
let areaCode = getAreasCode(index[0], index[1], index[2]);
// 触发事件
that.$emit("changeClick", provinces[index[0]], selectCitys[index[1]], selectAreas[index[2]], areaCode);
},
/**
* 确定按钮的点击事件
*/
handleNYZAreaSelect: function(e) {
var myEventDetail = e;
var myEventOption = {};
this.$emit('sureSelectArea', {
detail: myEventDetail
}, myEventOption);
// 复原初始状态
index = [0, 0, 0];
},
handleNYZAreaCancle: function(e) {
var that = this;
this.$emit('hideShow', {
detail: false
});
// 复原初始状态
index = [0, 0, 0];
}
},
/**
* 取消按钮的点击事件
*/
handleNYZAreaCancle: function(e) {
var that = this;
//console.log("e:" + JSON.stringify(e));
this.$emit('hideShow', {
detail: false
});
// 复原初始状态
index = [0, 0, 0];
}
}
</script>
<style scoped lang="scss">
.cc_area_view {
width: 100%;
position: fixed;
bottom: -1000px;
left: 0px;
background-color: #fff;
z-index: 21;
transition: all 0.3s;
}
.cc_area_pick_view {
height: 400px;
width: 100%;
}
.cc_area_colum_view {
line-height: 35px;
text-align: center;
font-size: 28upx;
}
.hide {
bottom: -1000upx;
transition: all 0.3s;
}
.show {
bottom: 0upx;
transition: all 0.3s;
}
.cc_area_view_btns {
background-color: #fff;
border-bottom: 1px solid #eeeeee;
font-size: 30upx;
padding: 18upx 0upx;
display: flex;
justify-content: space-between;
}
.cc_area_view_btns>text {
display: inline-block;
word-spacing: 4upx;
letter-spacing: 4upx;
}
.cc_area_view_btn_cancle {
color: #939393;
padding-right: 20upx;
padding-left: 25upx;
}
.cc_area_view_btn_sure {
float: right;
padding-left: 20upx;
padding-right: 25upx;
}
.cc_area_mask {
width: 100%;
height: 100vh;
background-color: rgba(28, 28, 28, 0.6);
position: absolute;
top: 0upx;
left: 0upx;
z-index: 20;
}
</style>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
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