Browse Source

客户模块

devlop
邓雄飞 4 years ago
parent
commit
40fdfea3e2
11 changed files with 172 additions and 154 deletions
  1. 2
      .gitignore
  2. 9
      App.vue
  3. 2
      components/bussiness-components/packingStationItem.vue
  4. 49
      components/qn-map/qn-map.nvue
  5. 22
      manifest.json
  6. 8
      pages/client-list/index.vue
  7. 57
      pages/client/index.nvue
  8. 53
      pages/login/index.vue
  9. 67
      pages/mine/index.vue
  10. 4
      utils/http/http.js
  11. 53
      utils/locationTransform.js

2
.gitignore

@ -2,6 +2,6 @@ jsconfig.json
.vscode/settings.json
components/qn-map/qn-map.vue
pages/client/index2.vue
./unpackage/**
unpackage/

9
App.vue

@ -7,14 +7,9 @@ export default {
if (!token) {
go2('login')
}
console.log('App launched')
},
onShow: function () {
console.log('App Show')
},
onHide: function () {
console.log('App Hide')
}
onShow: function () {},
onHide: function () {}
}
</script>

2
components/bussiness-components/packingStationItem.vue

@ -112,7 +112,7 @@ export default {
return phoneNum.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
}
}
return ''
return '--'
}
},
computed: {

49
components/qn-map/qn-map.nvue

@ -7,6 +7,7 @@
:longitude="centerPoint.longitude"
:latitude="centerPoint.latitude"
:markers="markers"
:show-location="true"
:scale="scale"
@labeltap="labeltap"
@regionchange="regionchange"
@ -62,23 +63,6 @@ export default {
}
})
},
location: {
handler(val) {
let data = {
longitude: val.longitude,
latitude: val.latitude,
scale: this.scale
}
if (this.mapContext) {
this.mapContext.moveToLocation({
longitude: val.longitude,
latitude: val.latitude
})
}
this.$emit('reset', data)
},
deep: true
}
},
methods: {
// 生成markers
@ -182,7 +166,36 @@ export default {
break
}
}, 500)
}
},
// 移动到当前坐标
moveTo({longitude,latitude,scale}) {
scale = Math.ceil(scale)
if(!isNaN(scale)) {
this.scale = scale
}else {
scale = null
}
let data = {
longitude: longitude,
latitude: latitude,
scale: scale || this.scale
}
if (this.mapContext) {
this.mapContext.moveToLocation({
longitude: longitude,
latitude: latitude,
success:res => {
console.log('移动success',res)
},
fail:err => {
console.log('移动fail',err)
}
})
}
setTimeout(() => {
this.$emit('reset', data)
},100)
}
}
}
</script>

22
manifest.json

@ -1,5 +1,5 @@
{
"name" : "paper-shop-app",
"name" : "纸掌柜",
"appid" : "__UNI__8C1E198",
"description" : "",
"versionName" : "1.0.0",
@ -24,21 +24,20 @@
},
/* */
"modules" : {
"Maps" : {}
"Maps" : {},
"Geolocation" : {},
"FaceID" : {}
},
/* */
"distribute" : {
/* android */
"android" : {
"permissions" : [
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
@ -56,7 +55,7 @@
"maps" : {
"amap" : {
"appkey_ios" : "5e4da36f4c1649ca28a1f8f795bcf5d2",
"appkey_android" : "2ced501c80ee5f6a74ba43ef7c2d36bd"
"appkey_android" : "877848546f7f3717101a17c33e1d4df3"
}
},
"payment" : {
@ -66,7 +65,14 @@
"UniversalLinks" : ""
}
},
"ad" : {}
"ad" : {},
"geolocation" : {
"amap" : {
"__platform__" : [ "ios", "android" ],
"appkey_ios" : "5e4da36f4c1649ca28a1f8f795bcf5d2",
"appkey_android" : "877848546f7f3717101a17c33e1d4df3"
}
}
}
},
"uniStatistics" : {

8
pages/client-list/index.vue

@ -98,7 +98,6 @@ export default {
getCompanyList({ ...this.params, ...this.pagination })
.then((res) => {
if (res) {
console.log('res:', res)
if (this.pagination.pageNum == 1) {
this.list = res.records
} else {
@ -116,7 +115,6 @@ export default {
},
downCallback() {
this.pagination.pageNum = 1
console.log('下拉刷新:')
this.getList()
.then(({ list, total }) => {
this.$refs.list.refreshSuccess({ list, total })
@ -126,12 +124,9 @@ export default {
})
},
upCallback(page) {
console.log('上拉加载:', page)
this.pagination.pageNum++
this.getList()
.then(({ list, total }) => {
console.log('list.length:', list.length)
console.log('total:', total)
this.$refs.list.loadSuccess({ list, total })
})
.catch(() => {
@ -142,8 +137,7 @@ export default {
watch: {
params: {
handler(val) {
console.log('val:', val)
// this.getList()
this.getList()
},
deep: true
}

57
pages/client/index.nvue

@ -14,9 +14,9 @@
</view>
</uni-nav-bar>
<div class="map_area">
<qn-map :location="location" :items="packingList" @dragMap="mapChange" @scaleMap="mapChange" @reset="mapChange" @labeltap="showInfo"></qn-map>
<qn-map ref="qnMap" :location="location" :items="packingList" @dragMap="mapChange" @scaleMap="mapChange" @reset="mapChange" @labeltap="showInfo"></qn-map>
<!-- 元素放在map下面才能展示 -->
<cover-view class="enquiry-area" v-show="enquiryList && enquiryList.length > 0 && !isClosed">
<cover-view class="enquiry-area" v-if="enquiryList && enquiryList.length > 0 && !isClosed">
<view class="enquiry-header">
<view class="notice">
<image style="width: 32rpx; height: 32rpx" src="/static/imgs/client/horn-icon.png"></image>
@ -61,10 +61,11 @@
<script>
import { go2 } from '@/utils/hook.js'
import wgs84togcj02 from '@/utils/locationTransform.js'
import qnMap from '@/components/qn-map/qn-map.nvue'
import packingStationItem from '@/components/bussiness-components/packingStationItem.vue'
import enquiryItem from './enquiryItem.vue'
import { getMapCompanyList, getInquiryList,getCompanyInfo } from '@/apis/clientApi'
import { getMapCompanyList, getInquiryList, getCompanyInfo } from '@/apis/clientApi'
export default {
components: { qnMap, enquiryItem, packingStationItem },
data() {
@ -84,15 +85,11 @@ export default {
enquiryList: [],
isClosed: false,
hasSelected: false,
selectedCompany:undefined
selectedCompany: undefined
}
},
methods: {
getSupplier(e) {
console.log('e:', e.detail.markerId)
},
mapChange(data) {
console.log('data:', data)
let params = {
cooperationState: 0,
km: 5,
@ -121,36 +118,32 @@ export default {
go2('add-user')
},
hideInfo() {
console.log('hide')
this.hasSelected = false
},
showInfo(id) {
console.log('id:', id)
getCompanyInfo({enterpriseId:id}).then(res => {
if(res) {
this.selectedCompany = res
this.hasSelected = true
}
})
getCompanyInfo({ enterpriseId: id }).then((res) => {
if (res) {
this.selectedCompany = res
this.hasSelected = true
}
})
},
locatePosition() {
console.log('locate begin')
uni.getLocation({
type: 'gcj02',
// type: 'gcj02',
type: 'wgs84',
success: (res) => {
console.log('success', res)
this.location.latitude = res.latitude
this.location.longitude = res.longitude
console.log('location success', res)
const { lat, lon } = wgs84togcj02(res.latitude, res.longitude)
this.$refs.qnMap.moveTo({ latitude: lat, longitude: lon })
},
fail: (err) => {
uni.showToast({
icon: 'error',
title: '定位失败:' + err.code
})
console.log('err', err)
}
})
console.log('locate end')
},
getProductionInfo(item) {
let res = []
@ -171,9 +164,8 @@ export default {
longitude: params.longitude,
size: params.size
}).then((res) => {
console.log('getPackingList', res)
if (res) {
this.packingList = res.records
this.packingList = res
}
})
},
@ -194,7 +186,7 @@ export default {
}
},
created() {
this.locatePosition()
// this.locatePosition()
getMapCompanyList({
cooperationState: 0,
km: 5,
@ -212,19 +204,16 @@ export default {
this.transitionTimer = null
},
onShow() {
if (!this.isClosed) {
this.transitionTimer = setInterval(() => {
this.curIndex == this.enquiryList.length - 1 ? (this.curIndex = 0) : this.curIndex++
}, 3000)
}
const token = this.$store.state.qnToken
if (token) {
getInquiryList({ pageNum: 1, pageSize: 10 }).then((res) => {
console.log('enquiryList', res)
if (res) {
this.enquiryList = res.records
console.log('this:', this.enquiryList)
if(this.enquiryList.length > 1 && !this.isClosed) {
this.transitionTimer = setInterval(() => {
this.curIndex == this.enquiryList.length - 1 ? (this.curIndex = 0) : this.curIndex++
}, 3000)
}
}
})
}

53
pages/login/index.vue

@ -1,14 +1,6 @@
<template>
<view>
<uni-nav-bar
:fixed="true"
color="#ffffff"
background-color="#ffffff"
:status-bar="true"
:border="false"
left-icon="closeempty"
@clickLeft="close"
/>
<uni-nav-bar :fixed="true" color="#ffffff" background-color="#ffffff" :status-bar="true" :border="false" left-icon="closeempty" @clickLeft="close" />
<view class="logo_area">
<image class="logo" src="/static/logo.png"></image>
<text class="title">纸掌柜</text>
@ -25,44 +17,22 @@
/>
</view>
<view class="captcha">
<uni-easyinput
v-model="captcha"
:inputBorder="false"
:placeholderStyle="'font-size:32rpx;'"
placeholder="请输入验证码"
:maxlength="6"
type="number"
/>
<uni-easyinput v-model="captcha" :inputBorder="false" :placeholderStyle="'font-size:32rpx;'" placeholder="请输入验证码" :maxlength="6" type="number" />
<view v-show="timer > 0" class="timer_area">
<text class="timer">{{ `(${timer}S后) ` }}</text>
<text class="timer_text">重新获取</text>
</view>
<text v-show="timer <= 0" class="code" @click="getCode">
获取验证码
</text>
</view>
<view
class="login-button"
@click="login"
:style="{ opacity: disabled ? '0.5' : '' }"
>
登录
<text v-show="timer <= 0" class="code" @click="getCode">获取验证码</text>
</view>
<view class="login-button" @click="login" :style="{ opacity: disabled ? '0.5' : '' }">登录</view>
</view>
<view class="agreement_area">
<checkbox-group @change="onCheck">
<checkbox
value="cb"
:checked="checked"
color="#000000"
style="transform: scale(0.7)"
/>
<checkbox value="cb" :checked="checked" color="#000000" style="transform: scale(0.7)" />
</checkbox-group>
<view class="agreement">
已阅读并同意纸掌柜
<text class="agreement_text" @click="jumpAgreement">
用户与隐私协议
</text>
<text class="agreement_text" @click="jumpAgreement">用户与隐私协议</text>
</view>
</view>
<!--
@ -123,7 +93,10 @@ export default {
verifiableAccount: this.phoneNumber,
verifiableAccountType: verificationType.PHONE
}).then((res) => {
console.log(res)
uni.showToast({
title: '验证码已发送',
icon: 'none'
})
})
},
//
@ -182,11 +155,7 @@ export default {
},
computed: {
disabled() {
return (
this.phoneNumber.trim() === '' ||
this.phoneNumber.trim().length != 11 ||
this.captcha.trim() === ''
)
return this.phoneNumber.trim() === '' || this.phoneNumber.trim().length != 11 || this.captcha.trim() === ''
}
}
}

67
pages/mine/index.vue

@ -1,45 +1,44 @@
<template>
<view class="content">
<view @click="logout">mine</view>
</view>
<view class="content">
<view @click="logout">mine</view>
</view>
</template>
<script>
import {exit} from '@/utils/hook.js'
export default {
methods:{
logout() {
console.log('123')
exit()
}
}
}
import { exit } from '@/utils/hook.js'
export default {
methods: {
logout() {
exit()
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
</style>

4
utils/http/http.js

@ -66,7 +66,7 @@ export default class Http {
}).catch((err) => {
// 吃掉请求产生的异常
// 后期可以记录
console.log('native response error', err)
console.error('native response error', err)
})
}
// config:{}
@ -101,7 +101,7 @@ export default class Http {
}
})
}).catch((err) => {
console.log('upload native err', err)
console.error('upload native err', err)
})
}
}

53
utils/locationTransform.js

@ -0,0 +1,53 @@
var pi = 3.14159265358979324
var a = 6378245.0
var ee = 0.00669342162296594323
/**
* WGS84坐标转换GCJ02坐标
* @param wgLatwgs纬度
* @param wgLonwgs经度
* @return Array[lat:gcj纬度,lon:gcj经度]
*/
function wgs84togcj02(wgLat, wgLon) {
var mgLat, mgLon
if (outOfChina(wgLat, wgLon)) {
mgLat = wgLat
mgLon = wgLon
return
}
var dLat = transformLat(wgLon - 105.0, wgLat - 35.0)
var dLon = transformLon(wgLon - 105.0, wgLat - 35.0)
var radLat = (wgLat / 180.0) * pi
var magic = Math.sin(radLat)
magic = 1 - ee * magic * magic
var sqrtMagic = Math.sqrt(magic)
dLat = (dLat * 180.0) / (((a * (1 - ee)) / (magic * sqrtMagic)) * pi)
dLon = (dLon * 180.0) / ((a / sqrtMagic) * Math.cos(radLat) * pi)
mgLat = wgLat + dLat
mgLon = wgLon + dLon
var arr = {}
arr['lat'] = mgLat
arr['lon'] = mgLon
return arr
}
function outOfChina(lat, lon) {
if (lon < 72.004 || lon > 137.8347) return true
if (lat < 0.8293 || lat > 55.8271) return true
return false
}
function transformLat(x, y) {
var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x))
ret += ((20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0) / 3.0
ret += ((20.0 * Math.sin(y * pi) + 40.0 * Math.sin((y / 3.0) * pi)) * 2.0) / 3.0
ret += ((160.0 * Math.sin((y / 12.0) * pi) + 320 * Math.sin((y * pi) / 30.0)) * 2.0) / 3.0
return ret
}
function transformLon(x, y) {
var ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x))
ret += ((20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0) / 3.0
ret += ((20.0 * Math.sin(x * pi) + 40.0 * Math.sin((x / 3.0) * pi)) * 2.0) / 3.0
ret += ((150.0 * Math.sin((x / 12.0) * pi) + 300.0 * Math.sin((x / 30.0) * pi)) * 2.0) / 3.0
return ret
}
export default wgs84togcj02
Loading…
Cancel
Save