Merge pull request 'token已存入Storage, 认证厂家详情接口初步完成' (#40) from DJ into dev

Reviewed-on: http://git.hchyun.com/feashow/pupil/pulls/40
This commit is contained in:
odjbin
2023-01-04 12:58:40 +00:00
4 changed files with 67 additions and 97 deletions

View File

@@ -38,7 +38,7 @@
methods: { methods: {
getNews() { getNews() {
this.$apiServe.getNews().then(res => { this.$apiServe.getNews().then(res => {
console.log('行业新闻', res.data.data) // console.log('行业新闻', res.data.data)
for (const item of res.data.data) { for (const item of res.data.data) {
item.pub_time_str = dateFormat(item.pub_time_str) item.pub_time_str = dateFormat(item.pub_time_str)
} }

View File

@@ -1,22 +1,22 @@
<template> <template>
<view> <view>
<u-swiper :list="swiperList" indicatorMode="line " width="750rpx" height="290rpx" radius="0" circular> <u-image :src="imgUrl+detailList.cover" width="750rpx" height="290rpx">
</u-swiper> </u-image>
<view class="feature"> <view class="feature">
<text class="one_title">经营范围及特色</text> <text class="one_title">经营范围及特色</text>
<view class="green_block"> <view class="green_block">
<text class="green_features">{{features}}</text> <text class="green_features">{{detailList.desc}}</text>
</view> </view>
</view> </view>
<view class="introduce"> <view class="introduce">
<view class="introduce_title">企业介绍</view> <view class="introduce_title">企业介绍</view>
<text class="business_introduce">{{business_introduce}}</text> <text class="business_introduce">{{detailList.content}}</text>
</view> </view>
<view class="show"> <view class="show">
<view class="introduce_title">企业展示</view> <view class="introduce_title">企业展示</view>
<u-grid :border="false" col="4"> <u-grid :border="false" col="4">
<u-grid-item v-for="(listItem,listIndex) in showList" :key="listIndex"> <u-grid-item v-for="(listItem,listIndex) in detailList.images" :key="listIndex">
<u--image :src="listItem.src" width="170rpx" height="170rpx" :lazy-load="true"> <u--image :src="imgUrl+listItem" width="170rpx" height="170rpx" :lazy-load="true">
</u--image> </u--image>
</u-grid-item> </u-grid-item>
</u-grid> </u-grid>
@@ -34,37 +34,23 @@
return { return {
id: '', id: '',
detailList: [], detailList: [],
features: '活冻鲍鱼,冻煮鲍鱼,鲍鱼罐头 佛跳墙,海螺片', imgUrl: ''
business_introduce: '福建省海纳川食品有限公司是一家从事水产养殖,加工与销售为一体的现代化企业,公司主要加工:活冻鲍鱼,溏心皇金鲍,兰花蟹,黄金鲍片,佛跳墙,大盆菜,火锅小章鱼,鲨鱼礼盒等系列产品。公司位于福建省自由贸易试验区马尾片区,离全国大的水产交易市场--马尾名成水产市场不到一公里,这里交通方便,商贾云集,冷链物流通达全国。',
showList: [{
src: '/static/report/zhanwei_xf(1).png'
}, {
src: '/static/report/zhanwei_xf(1).png'
}, {
src: '/static/report/zhanwei_xf(1).png'
},
{
src: '/static/report/zhanwei_xf(1).png'
},
],
swiperList: [
'/static/detail/cj_bg.png',
'/static/detail/cj_bg.png'
]
} }
}, },
onLoad(option) { onLoad(option) {
// console.log('认证厂家id', option.id);
this.id = option.id this.id = option.id
this.getCertifiedCjDetail() this.getCertifiedCjDetail()
this.imgUrl = uni.getStorageSync('img_url')
}, },
methods: { methods: {
//获取认证厂家详情 //获取认证厂家详情
getCertifiedCjDetail() { getCertifiedCjDetail() {
this.$apiServe.getCertifiedCjDetail(this.id).then(res => { this.$apiServe.getCertifiedCjDetail(this.id).then(res => {
console.log('认证厂家详情页', res) console.log('认证厂家详情页', res.data.data)
// this.detailList = res.data.data let data = res.data.data
data.images = data.images.split(';')
console.log('data.images', data.images);
this.detailList = data
}).finally(_ => {}) }).finally(_ => {})
}, },
} }

View File

@@ -75,14 +75,48 @@
this.getCategories() this.getCategories()
this.getBanner() this.getBanner()
this.getImgUrl() this.getImgUrl()
this.getToken()
this.imgUrl = uni.getStorageSync('img_url') this.imgUrl = uni.getStorageSync('img_url')
}, },
methods: { methods: {
getToken() {
var that = this
uni.login({
"provider": "weixin",
"onlyAuthorize": true, // 微信登录仅请求授权认证
success: function(event) {
const {
code
} = event
console.log("登录code", code);
let fromData = {
code: code
}
that.$apiServe.login({
code: code
}).then(res => {
console.log('登录code换取的用户', res.data.data);
uni.setStorageSync('token', res.data.data.token);
})
},
fail: function(err) {
// 登录授权失败
// err.code是错误码
}
})
},
//获取手机code
getphonenumber(e) {
let that = this
// const {
// code
// } = e.detail;
// console.log("手机code : ", code);
},
//获取子组件的getProducts方法返回数据的length用于当length为0时取消发送请求 //获取子组件的getProducts方法返回数据的length用于当length为0时取消发送请求
getChild(e) { getChild(e) {
this.reachBottomLength = e this.reachBottomLength = e
}, },
//获取一级分类 //获取一级分类
getCategories() { getCategories() {
@@ -106,43 +140,6 @@
url: '../../packageSearch/search/search' url: '../../packageSearch/search/search'
}) })
}, },
getphonenumber(e) {
let that = this
console.log(e);
//必须要公司注册,且微信认证过的小程序,才能获取到手机号的接口权限
if (e.detail.errMsg == "getPhoneNumber:fail ") {
console.log('用户拒绝提供手机号');
} else {
console.log('用户同意提供手机号');
}
const {
phoneCode
} = e.detail;
console.log("手机code : ", phoneCode);
uni.login({
"provider": "weixin",
"onlyAuthorize": true, // 微信登录仅请求授权认证
success: function(event) {
const {
code
} = event
console.log("登录code", code);
//客户端成功获取授权临时票据code,向业务服务器发起登录请求。
// 调用登录接口 拿到token 传手机code,更新手机号码
let fromData = {
code: code
}
that.$apiServe.login(fromData).then(res => {
console.log(res);
})
},
fail: function(err) {
// 登录授权失败
// err.code是错误码
}
})
},
//点击一级分类跳转到分类页 //点击一级分类跳转到分类页
toClassify() { toClassify() {
uni.navigateTo({ uni.navigateTo({

View File

@@ -17,7 +17,8 @@ function isOutTime(res) {
const service = { const service = {
get(url, data) { get(url, data) {
const header = {} const header = {}
header['Authorization'] = 'Bearer ' + uni.getStorageSync('token') // header['Authorization'] = 'Bearer ' + uni.getStorageSync('token')
header['token'] = uni.getStorageSync('token')
header['content-type'] = 'application/json' header['content-type'] = 'application/json'
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
@@ -42,15 +43,8 @@ const service = {
}, },
post(url, data, isLogin) { post(url, data, isLogin) {
const header = {} const header = {}
if (isLogin) { header['token'] = uni.getStorageSync('token')
// header['content-type'] = 'application/x-www-form-urlencoded'; header['content-type'] = 'application/json'
console.log(isLogin)
header['Authorization'] = ''
} else {
header['Authorization'] = 'Bearer ' + uni.getStorageSync('token')
header['content-type'] = 'application/json'
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
method: 'post', method: 'post',
@@ -59,7 +53,6 @@ const service = {
header: header, header: header,
timeout: 30000, timeout: 30000,
success: res => { success: res => {
console.log(1111, res)
uni.hideLoading() uni.hideLoading()
// if (res.data.exception === 'UnAuthorizedException') { // if (res.data.exception === 'UnAuthorizedException') {
// let pages = getCurrentPages() // let pages = getCurrentPages()
@@ -99,14 +92,8 @@ const service = {
}, },
put(url, data, isLogin) { put(url, data, isLogin) {
const header = {} const header = {}
header['token'] = uni.getStorageSync('token')
if (isLogin) { header['content-type'] = 'application/json'
header['content-type'] = 'application/x-www-form-urlencoded'
} else {
header['Authorization'] = 'Bearer ' + uni.getStorageSync('token')
header['content-type'] = 'application/json'
}
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
method: 'put', method: 'put',
@@ -117,7 +104,6 @@ const service = {
isOutTime(res) isOutTime(res)
reject(res) reject(res)
} }
resolve(res) resolve(res)
}, },
data: data, data: data,
@@ -174,11 +160,18 @@ const toast = {
const apiService = { const apiService = {
uploadImgUrl: serverHost, uploadImgUrl: serverHost,
imgUrl: serverHost, imgUrl: serverHost,
login: data => { // login: data => {
data = Object.assign(data || {}, {}) // data = Object.assign(data || {}, {})
const url = `/api` // const url = `/api`
// return new Promise((resolve, reject) => {
// resolve(service.post(url, data, true))
// })
// },
//登录接口
login(data) {
const url = `/login/mnpLogin`
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve(service.post(url, data, true)) resolve(service.post(url, data))
}) })
}, },
// 获取首页轮播图 // 获取首页轮播图
@@ -230,13 +223,7 @@ const apiService = {
resolve(service.get(url, id)) resolve(service.get(url, id))
}) })
}, },
login: data => {
data = Object.assign(data || {}, {})
const url = `/api`
return new Promise((resolve, reject) => {
resolve(service.post(url, data, true))
})
},
// 获取首页分类Tag // 获取首页分类Tag
getTags(data) { getTags(data) {
const url = `/home/tags` const url = `/home/tags`