diff --git a/App.vue b/App.vue index 5067e3d..3d847b7 100644 --- a/App.vue +++ b/App.vue @@ -1,7 +1,11 @@ diff --git a/package_sub/pages/AddOrder/AddOrder.vue b/package_sub/pages/AddOrder/AddOrder.vue index 990d98b..f0dcc10 100644 --- a/package_sub/pages/AddOrder/AddOrder.vue +++ b/package_sub/pages/AddOrder/AddOrder.vue @@ -189,7 +189,7 @@ export default { next () { if (!this.isAuth && this.currentStep === 0) { this.$refs.uTips.show({ - title: '请认真阅读《服务条款同意书》!', + title: '请认真阅读《服务条款同意书》', type: 'warning', duration: '2000' }) diff --git a/package_sub/pages/ServiceList/ServiceList.vue b/package_sub/pages/ServiceList/ServiceList.vue index ce96ba1..729cbe1 100644 --- a/package_sub/pages/ServiceList/ServiceList.vue +++ b/package_sub/pages/ServiceList/ServiceList.vue @@ -1,9 +1,9 @@ @@ -54,8 +53,17 @@ export default { 'height': '60rpx', 'line-height': '60rpx' }, - isShowCity: false }; + }, + mounted() { + this.$store.dispatch('getLocation') + }, + methods: { + toOrder(item) { + this.$u.route({ + url: '/package_sub/pages/AddOrder/AddOrder' + }) + } } } diff --git a/pages.json b/pages.json index 3545951..e6fc242 100644 --- a/pages.json +++ b/pages.json @@ -12,8 +12,7 @@ { "path": "pages/order/order", "style": { - "navigationBarTitleText": "", - "enablePullDownRefresh": true + "navigationBarTitleText": "订单列表" } }, { @@ -28,6 +27,12 @@ "style": { "navigationBarTitleText": "城市选择" } + }, + { + "path": "pages/login/login", + "style": { + "navigationStyle": "custom" + } } ], "subPackages": [ diff --git a/pages/CitySelect/CitySelect.vue b/pages/CitySelect/CitySelect.vue index 08bf66c..2fe474f 100644 --- a/pages/CitySelect/CitySelect.vue +++ b/pages/CitySelect/CitySelect.vue @@ -2,12 +2,14 @@ @@ -22,12 +24,8 @@ export default { data() { return { //需要构建索引参数的名称(注意:传递的对象里面必须要有这个名称的参数) - formatName: 'title', //当前城市 - activeCity: { - id: 1, - title: '南京市' - }, + activeCity: {}, //热门城市 hotCity: [ { @@ -40,26 +38,24 @@ export default { } ], //显示的城市数据 - obtainCitys: [ - { - id: 0, - title: '南京' - }, - { - id: 1, - title: '北京' - }, - { - id: 2, - title: '天津' - }, - { - id: 3, - title: '东京' - } - ] + obtainCitys: [] }; }, + watch: { + vuex_location: { + handler:function(newVal, oldVal) { + this.activeCity = { + cityName: newVal.city, + cityCode: newVal.cityCode + } + }, + deep: true, + immediate: true + } + }, + mounted() { + this.$store.dispatch('getLocation') + }, onLoad () { //动态更新数据 setTimeout(() => { @@ -67,8 +63,8 @@ export default { this.formatName = 'cityName' //修改当前城市 this.activeCity = { - cityName: '南京', - cityCode: 110100 + cityName: this.vuex_location.city, + cityCode: this.vuex_location.cityCode } //修改热门城市 this.hotCity = [ @@ -83,25 +79,16 @@ export default { ] //修改构建索引数据 this.obtainCitys = citys - uni.showToast({ - icon: 'none', - title: '更新数据成功', - // #ifdef MP-WEIXIN - duration: 3000, - // #endif - mask: true - }) - }, 500) + }, 0) }, methods: { + refreshLocation() { + this.$store.dispatch('getLocation') + }, cityClick(item) { - uni.showToast({ - icon: 'none', - title: 'item: ' + JSON.stringify(item), - // #ifdef MP-WEIXIN - duration: 3000, - // #endif - mask: true + this.$store.commit('SET_CITY',{ + cityName: item.cityName, + cityCode: item.cityCode }) } } diff --git a/pages/index/index.vue b/pages/index/index.vue index 0d40bb9..0aba48a 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -8,9 +8,9 @@ alt="" > - + - {{ location.city.replace(/(市|区|县)/,'') }} + {{ vuex_location.city.replace(/(市|区|县)/,'') }} @@ -37,7 +37,7 @@ - 苏州 + {{ vuex_location.city.replace(/(市|区|县)/,'') }} @@ -144,22 +144,24 @@ - + @@ -340,9 +303,15 @@ export default { font-size: 30rpx; letter-spacing: 3rpx; font-weight: 500; + display: flex; + align-items: center; - & > text { + & > view { padding: 0 13rpx; + max-width: 160rpx; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; } } .icon { @@ -400,9 +369,15 @@ export default { font-weight: 500; white-space: nowrap; padding: 0 16rpx; + display: flex; + align-items: center; - & > text { + & > view { padding: 0 10rpx; + max-width: 160rpx; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; } } &__search { diff --git a/pages/login/login.vue b/pages/login/login.vue new file mode 100644 index 0000000..ff9b236 --- /dev/null +++ b/pages/login/login.vue @@ -0,0 +1,169 @@ + + + + + + diff --git a/pages/order/order.vue b/pages/order/order.vue index 4a60ca6..e9809f9 100644 --- a/pages/order/order.vue +++ b/pages/order/order.vue @@ -1,24 +1,307 @@ - + + diff --git a/static/login/bkg.png b/static/login/bkg.png new file mode 100644 index 0000000..6136f4d Binary files /dev/null and b/static/login/bkg.png differ diff --git a/static/login/bottom.png b/static/login/bottom.png new file mode 100644 index 0000000..f48f492 Binary files /dev/null and b/static/login/bottom.png differ diff --git a/static/login/logo.png b/static/login/logo.png new file mode 100644 index 0000000..73dd4d5 Binary files /dev/null and b/static/login/logo.png differ diff --git a/store/index.js b/store/index.js index 3dfcae8..d2a59a6 100644 --- a/store/index.js +++ b/store/index.js @@ -7,7 +7,7 @@ let lifeData = {}; try{ // 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的 lifeData = uni.getStorageSync('lifeData'); -}catch(e){ +} catch(e) { } @@ -34,6 +34,13 @@ const store = new Vuex.Store({ // 加上vuex_前缀,是防止变量名冲突,也让人一目了然 // 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式 vuex_version: '1.0.0', + + vuex_location: { + latitude: '', + longitude: '', + city: '', + cityCode: '' + } }, mutations: { $uStore(state, payload) { @@ -55,6 +62,49 @@ const store = new Vuex.Store({ } // 保存变量到本地,见顶部函数定义 saveLifeData(saveKey, state[saveKey]) + }, + + SET_CITY(state, { cityName, cityCode }) { + state.vuex_location.city = cityName + state.vuex_location.cityCode = cityCode + } + }, + actions: { + async getLocation({ state }) { + try { + const [err, res] = await uni.getLocation({ + type: 'gcj02' + }) + if (err) { + await Promise.reject(err) + } + console.log(state, res) + state.vuex_location.latitude = res.latitude; + state.vuex_location.longitude = res.longitude; + const address = await new Promise((resolve, reject) => { + Vue.prototype.$qqmapsdk.reverseGeocoder({ + location: { + latitude: res.latitude, + longitude: res.longitude + }, + success: address => resolve(address), + fail: error => reject(error) + }) + }) + console.log('address', address) + if (!!address.status) { + await Promise.reject(address.message) + } + state.vuex_location.city = address?.result?.ad_info.city + state.vuex_location.cityCode = address?.result?.ad_info?.city_code + } catch (err) { + console.error(err) + uni.showToast({ + title: '获取定位失败', + icon: 'none', + duration: 2000 + }) + } } } })