token已存入Storage, 认证厂家详情接口初步完成

This commit is contained in:
clay
2023-01-04 20:58:04 +08:00
parent 27787d3300
commit 2417d8fe28
4 changed files with 67 additions and 97 deletions

View File

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

View File

@@ -1,22 +1,22 @@
<template>
<view>
<u-swiper :list="swiperList" indicatorMode="line " width="750rpx" height="290rpx" radius="0" circular>
</u-swiper>
<u-image :src="imgUrl+detailList.cover" width="750rpx" height="290rpx">
</u-image>
<view class="feature">
<text class="one_title">经营范围及特色</text>
<view class="green_block">
<text class="green_features">{{features}}</text>
<text class="green_features">{{detailList.desc}}</text>
</view>
</view>
<view class="introduce">
<view class="introduce_title">企业介绍</view>
<text class="business_introduce">{{business_introduce}}</text>
<text class="business_introduce">{{detailList.content}}</text>
</view>
<view class="show">
<view class="introduce_title">企业展示</view>
<u-grid :border="false" col="4">
<u-grid-item v-for="(listItem,listIndex) in showList" :key="listIndex">
<u--image :src="listItem.src" width="170rpx" height="170rpx" :lazy-load="true">
<u-grid-item v-for="(listItem,listIndex) in detailList.images" :key="listIndex">
<u--image :src="imgUrl+listItem" width="170rpx" height="170rpx" :lazy-load="true">
</u--image>
</u-grid-item>
</u-grid>
@@ -34,37 +34,23 @@
return {
id: '',
detailList: [],
features: '活冻鲍鱼,冻煮鲍鱼,鲍鱼罐头 佛跳墙,海螺片',
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'
]
imgUrl: ''
}
},
onLoad(option) {
// console.log('认证厂家id', option.id);
this.id = option.id
this.getCertifiedCjDetail()
this.imgUrl = uni.getStorageSync('img_url')
},
methods: {
//获取认证厂家详情
getCertifiedCjDetail() {
this.$apiServe.getCertifiedCjDetail(this.id).then(res => {
console.log('认证厂家详情页', res)
// this.detailList = res.data.data
console.log('认证厂家详情页', res.data.data)
let data = res.data.data
data.images = data.images.split(';')
console.log('data.images', data.images);
this.detailList = data
}).finally(_ => {})
},
}

View File

@@ -75,14 +75,48 @@
this.getCategories()
this.getBanner()
this.getImgUrl()
this.getToken()
this.imgUrl = uni.getStorageSync('img_url')
},
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时取消发送请求
getChild(e) {
this.reachBottomLength = e
},
//获取一级分类
getCategories() {
@@ -106,43 +140,6 @@
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() {
uni.navigateTo({

View File

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