From ae72286ad7d6e777fcb948a9caa658045b4a2d5b Mon Sep 17 00:00:00 2001 From: 396316021 <396316021@qq.com> Date: Mon, 14 Oct 2024 20:32:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=82=E6=B0=91=E4=BA=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/user.js | 5 ++- components/AdvisorPage/index.vue | 1 + config/host.js | 3 +- index.html | 2 +- main.js | 2 + pages/Login/index.vue | 2 +- uni_modules/m-view/index.js | 5 ++- uni_modules/m-view/lib/cloud-lib.js | 60 +++++++++++++++++++++++++++++ 8 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 uni_modules/m-view/lib/cloud-lib.js diff --git a/api/user.js b/api/user.js index 7971dcc..b1812ba 100644 --- a/api/user.js +++ b/api/user.js @@ -1,5 +1,6 @@ import request from "@/utils/request.js"; import {host,cloud_host} from "@/config/host.js"; +import {test_host} from "../config/host"; /** * 登录 @@ -8,7 +9,7 @@ import {host,cloud_host} from "@/config/host.js"; export function testLogin(data) { return request({ - url: `${host}/common/fake-login`, + url: `${test_host}/common/fake-login`, method: "get", data }); @@ -23,7 +24,7 @@ export function appletLogin(data) { } export function cloudLogin(data) { return request({ - url: `${host}/tfsmy/auth`, + url: `${test_host}/tfsmy/auth`, method: "get", data }); diff --git a/components/AdvisorPage/index.vue b/components/AdvisorPage/index.vue index 1f84093..98ba72c 100644 --- a/components/AdvisorPage/index.vue +++ b/components/AdvisorPage/index.vue @@ -597,6 +597,7 @@ export default { sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 sourceType: ['album'], //从相册选择 success: function (res) { + console.log('res',res) that.uploadAvatar({detail: {avatarUrl: res.tempFilePaths}}); } }); diff --git a/config/host.js b/config/host.js index baee05b..f3ef5af 100644 --- a/config/host.js +++ b/config/host.js @@ -1,6 +1,7 @@ // const host='http://192.168.2.92:9505/api' const host='https://nxr.fanyiguanjia.com/api' // const host='https://nxr.test.fanyiguanjia.com/api' +const test_host='https://nxr.test.fanyiguanjia.com/api' const h5_host='https://nxr.smy.fanyiguanjia.com/' const cloud_host='https://cdpre.tfsmy.com/api' @@ -10,4 +11,4 @@ const imghost='https://nxr.fanyiguanjia.com/icon/static/image' const title = '暖新人' // const codehost='http://code.baomingle.cn' const oss = 'https://fanyi-guanjia-1.'+'oss-cn-chengdu.aliyuncs.com' -export {host,imghost,title,oss,h5_host,cloud_host} \ No newline at end of file +export {host,imghost,title,oss,h5_host,cloud_host,test_host} \ No newline at end of file diff --git a/index.html b/index.html index f1c4253..dd28f6a 100644 --- a/index.html +++ b/index.html @@ -15,7 +15,7 @@
- + diff --git a/main.js b/main.js index 2860e31..febe998 100644 --- a/main.js +++ b/main.js @@ -25,6 +25,8 @@ export function createApp() { app.use(mView) app.use(store) uni.$u.config.unit = 'rpx' + + return { app } diff --git a/pages/Login/index.vue b/pages/Login/index.vue index e1fb092..6a1e66a 100644 --- a/pages/Login/index.vue +++ b/pages/Login/index.vue @@ -188,7 +188,7 @@ export default { }, login(){ testLogin({ - user_id:1 + user_id:55 }).then((res) => { uni.setStorageSync('token',res.data.token); userDetail().then((res) => { diff --git a/uni_modules/m-view/index.js b/uni_modules/m-view/index.js index 0a7689b..e1f9a6e 100644 --- a/uni_modules/m-view/index.js +++ b/uni_modules/m-view/index.js @@ -1,12 +1,15 @@ import api from './lib/functions.js' import tools from './lib/tools.js' +import cloud from './lib/cloud-lib.js' import service from "@/uni_modules/m-view/lib/request"; const $m = { ...api, ...tools, service } - +// #ifdef H5 +cloud.build(); +// #endif // $m挂载到uni对象上 uni.$m = $m diff --git a/uni_modules/m-view/lib/cloud-lib.js b/uni_modules/m-view/lib/cloud-lib.js new file mode 100644 index 0000000..5b43a7e --- /dev/null +++ b/uni_modules/m-view/lib/cloud-lib.js @@ -0,0 +1,60 @@ +function dataURLToBlob(cropperData) { + let arr = cropperData.split(","); + console.log('arr',arr) + let mime = arr[0].match(/:(.*?);/)[1]; + let blobStr = atob(arr[1]); + let n = blobStr.length; + let u8arr = new Uint8Array(n); + while (n--) { + u8arr[n] = blobStr.charCodeAt(n); + } + return URL.createObjectURL(new Blob([u8arr], { type: mime })) +} + +export default { + build() { + uni.chooseImage = (params) => { + try { + if('compile' in params)params.compile(); + eshimin.getLocalPicture({ + onResponse:function (res) { + if('success' in params)params.success([dataURLToBlob(res.img)]); + } + }); + }catch (e){ + console.log(e) + if('fail' in params)params.fail(e); + } + } + uni.getLocation = (params) => { + try { + console.log('getLocation', params) + if('compile' in params)params.compile(); + eshimin.getLocation({ + onResponse:function (res) { + if('success' in params)params.success(res); + } + }); + }catch (e){ + console.log(e) + if('fail' in params)params.fail(e); + } + } + uni.makePhoneCall = (params) => { + try { + console.log('makePhoneCall', params) + if('compile' in params)params.compile(); + eshimin.getLocation({ + phoneNum:params.phoneNumber, + onResponse:function (res) { + if('success' in params)params.success(res); + } + }); + }catch (e){ + console.log(e) + if('fail' in params)params.fail(e); + } + } + }, +}; +