feat: 首页增加性能优化, 登录界面优化
This commit is contained in:
parent
ebe2ed6873
commit
1e4a8b8ed9
@ -237,19 +237,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
onShow() {
|
|
||||||
|
|
||||||
if (uni.getStorageSync('city')) {
|
|
||||||
this.currentCity = {
|
|
||||||
city: uni.getStorageSync('city')
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
uni.setStorageSync('city', uni.getStorageSync('Usercity'))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
swipers(e) {
|
swipers(e) {
|
||||||
this.currentIdx = e.detail.current
|
this.currentIdx = e.detail.current
|
||||||
@ -301,7 +288,7 @@
|
|||||||
that.CommunityList = that.CommunityList.concat(res.rows || []);
|
that.CommunityList = that.CommunityList.concat(res.rows || []);
|
||||||
that.flag = flag;
|
that.flag = flag;
|
||||||
that.page_num = that.page_num + 1;
|
that.page_num = that.page_num + 1;
|
||||||
console.log(that.CommunityList);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getHostInfo() {
|
getHostInfo() {
|
||||||
@ -334,6 +321,10 @@
|
|||||||
if (idx == 0) {
|
if (idx == 0) {
|
||||||
this.getCommunityList();
|
this.getCommunityList();
|
||||||
} else if (idx == 1) {
|
} else if (idx == 1) {
|
||||||
|
if (!uni.getStorageSync('ctoken')) {
|
||||||
|
uni.navigateTo({ url: '/pages/login/login' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.getServerList();
|
this.getServerList();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -434,8 +425,6 @@
|
|||||||
if (res.rows.length) {
|
if (res.rows.length) {
|
||||||
res.rows.forEach(item => {
|
res.rows.forEach(item => {
|
||||||
item.icon_src = picUrl + item.icon_src
|
item.icon_src = picUrl + item.icon_src
|
||||||
|
|
||||||
console.log(item.icon_src,'banner1');
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.tabList = res.rows
|
this.tabList = res.rows
|
||||||
@ -500,26 +489,33 @@
|
|||||||
mask: true
|
mask: true
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const [provRes, cityRes, distRes] = await Promise.all([
|
const proviceList = uni.getStorageSync('proviceList');
|
||||||
this.getProvList(),
|
const cityList = uni.getStorageSync('cityList');
|
||||||
this.getCityList(),
|
const businessList = uni.getStorageSync('businessList');
|
||||||
this.getDistList(),
|
|
||||||
])
|
let cascaderOptions = null;
|
||||||
|
|
||||||
|
// 有缓存数据时 不进行接口请求
|
||||||
|
if (!proviceList || !cityList || !businessList) {
|
||||||
|
const [provRes, cityRes, distRes] = await Promise.all([
|
||||||
|
this.getProvList(),
|
||||||
|
this.getCityList(),
|
||||||
|
this.getDistList(),
|
||||||
|
])
|
||||||
|
|
||||||
|
uni.setStorageSync('proviceList',provRes.rows)
|
||||||
|
uni.setStorageSync('cityList',cityRes.rows)
|
||||||
|
uni.setStorageSync('businessList',distRes.rows)
|
||||||
|
|
||||||
uni.setStorageSync('proviceList',provRes.rows)
|
cascaderOptions = provRes?.rows.map(province => ({
|
||||||
uni.setStorageSync('cityList',cityRes.rows)
|
|
||||||
uni.setStorageSync('businessList',distRes.rows)
|
|
||||||
|
|
||||||
|
|
||||||
let cascaderOptions = provRes.rows.map(province => ({
|
|
||||||
value: province.city_id, // 使用 city_id 作为省的值
|
value: province.city_id, // 使用 city_id 作为省的值
|
||||||
label: province.name, // 使用 name 作为省的显示文本
|
label: province.name, // 使用 name 作为省的显示文本
|
||||||
children: cityRes.rows
|
children: cityRes?.rows
|
||||||
.filter(city => city.city_id === province.city_id) // 注意:这里需要确认关联字段
|
.filter(city => city.city_id === province.city_id) // 注意:这里需要确认关联字段
|
||||||
.map(city => ({
|
.map(city => ({
|
||||||
value: city.area_id, // 使用 area_id 作为市的值
|
value: city.area_id, // 使用 area_id 作为市的值
|
||||||
label: city.area_name, // 使用 area_name 作为市的显示文本
|
label: city.area_name, // 使用 area_name 作为市的显示文本
|
||||||
children: distRes.rows
|
children: distRes?.rows
|
||||||
.filter(district => district.area_id === city.area_id) // 注意:这里需要确认关联字段
|
.filter(district => district.area_id === city.area_id) // 注意:这里需要确认关联字段
|
||||||
.map(district => ({
|
.map(district => ({
|
||||||
value: district.business_id, // 使用 business_id 作为区的值
|
value: district.business_id, // 使用 business_id 作为区的值
|
||||||
@ -527,10 +523,32 @@
|
|||||||
}))
|
}))
|
||||||
}))
|
}))
|
||||||
}))
|
}))
|
||||||
|
console.log('接口返回数据处理 省市区', cascaderOptions);
|
||||||
console.log(cascaderOptions,'cascaderOptions');
|
};
|
||||||
|
|
||||||
|
// 如果读的接口返回数据,则不二次进行处理, 否则对缓存数据进行二次处理
|
||||||
|
if (!cascaderOptions) {
|
||||||
|
cascaderOptions = proviceList.map(province => ({
|
||||||
|
value: province.city_id, // 使用 city_id 作为省的值
|
||||||
|
label: province.name, // 使用 name 作为省的显示文本
|
||||||
|
children: cityList
|
||||||
|
.filter(city => city.city_id === province.city_id) // 注意:这里需要确认关联字段
|
||||||
|
.map(city => ({
|
||||||
|
value: city.area_id, // 使用 area_id 作为市的值
|
||||||
|
label: city.area_name, // 使用 area_name 作为市的显示文本
|
||||||
|
children: businessList
|
||||||
|
.filter(district => district.area_id === city.area_id) // 注意:这里需要确认关联字段
|
||||||
|
.map(district => ({
|
||||||
|
value: district.business_id, // 使用 business_id 作为区的值
|
||||||
|
label: district.business_name // 使用 business_name 作为区的显示文本
|
||||||
|
}))
|
||||||
|
}))
|
||||||
|
}))
|
||||||
|
console.log('读缓存数据处理的省市区', cascaderOptions)
|
||||||
|
}
|
||||||
|
|
||||||
this.currentProviceCity = this.getProvinceCityId(cascaderOptions,uni.getStorageSync('city'))
|
this.currentProviceCity = this.getProvinceCityId(cascaderOptions,uni.getStorageSync('city'))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await this.getButtonList()
|
await this.getButtonList()
|
||||||
@ -631,8 +649,6 @@
|
|||||||
this.getHostInfo()
|
this.getHostInfo()
|
||||||
const meun = menuButtonInfo();
|
const meun = menuButtonInfo();
|
||||||
this.top = meun.height + meun.top;
|
this.top = meun.height + meun.top;
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
if (uni.getStorageSync('city')) {
|
if (uni.getStorageSync('city')) {
|
||||||
|
|||||||
@ -57,8 +57,10 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
headerLoginClick() {
|
headerLoginClick() {
|
||||||
let _this = this;
|
uni.showLoading({
|
||||||
|
title: '登录中...',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
if (this.loginChannel === 'android' || this.loginChannel === 'ios') {
|
if (this.loginChannel === 'android' || this.loginChannel === 'ios') {
|
||||||
this.appLogin();
|
this.appLogin();
|
||||||
return;
|
return;
|
||||||
@ -67,13 +69,11 @@
|
|||||||
uni.login({
|
uni.login({
|
||||||
onlyAuthorize: true,
|
onlyAuthorize: true,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log('res', res);
|
|
||||||
// return
|
|
||||||
request(apiArr.login, 'POST', {
|
request(apiArr.login, 'POST', {
|
||||||
code: res.code,
|
code: res.code,
|
||||||
phone: '',
|
phone: '',
|
||||||
password: '',
|
password: '',
|
||||||
}).then((loginRes) => {
|
}, { silent: false }).then((loginRes) => {
|
||||||
// 存储用户信息
|
// 存储用户信息
|
||||||
uni.setStorageSync('ctoken', loginRes.token);
|
uni.setStorageSync('ctoken', loginRes.token);
|
||||||
uni.setStorageSync('is_deal', loginRes.is_deal);
|
uni.setStorageSync('is_deal', loginRes.is_deal);
|
||||||
@ -83,9 +83,9 @@
|
|||||||
|
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
request(apiArr.loginInfo, 'POST', {}, {
|
request(apiArr.loginInfo, 'POST', {
|
||||||
token: loginRes.token
|
token: loginRes.token
|
||||||
}).then((res2) => {
|
}, { silent: false } ).then((res2) => {
|
||||||
if (res2.error) return;
|
if (res2.error) return;
|
||||||
// 保存userId 后续接口使用
|
// 保存userId 后续接口使用
|
||||||
uni.setStorageSync('userId', res2.user_id);
|
uni.setStorageSync('userId', res2.user_id);
|
||||||
@ -93,8 +93,8 @@
|
|||||||
uni.setStorageSync('shopId', res2.wshop_id);
|
uni.setStorageSync('shopId', res2.wshop_id);
|
||||||
this.isLogin = true;
|
this.isLogin = true;
|
||||||
})
|
})
|
||||||
uni.hideLoading();
|
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
|
uni.hideLoading();
|
||||||
console.log('登录接口错误', err);
|
console.log('登录接口错误', err);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -103,14 +103,13 @@
|
|||||||
|
|
||||||
// 小程序登录获取手机号接口
|
// 小程序登录获取手机号接口
|
||||||
getPhoneNumber(event) {
|
getPhoneNumber(event) {
|
||||||
let that = this
|
console.log('小程序登录获取手机号', event);
|
||||||
console.log('小程序登录获取手机号');
|
|
||||||
const { isLogin } = this;
|
const { isLogin } = this;
|
||||||
console.log('获取信息', event);
|
|
||||||
if (event.detail.errMsg === "getPhoneNumber:ok") {
|
if (event.detail.errMsg === "getPhoneNumber:ok") {
|
||||||
request(apiArr.loginGetPhone, 'POST', {
|
request(apiArr.loginGetPhone, 'POST', {
|
||||||
code: event.detail.code
|
code: event.detail.code
|
||||||
}).then((res) => {
|
}, { silent: false }).then((res) => {
|
||||||
|
uni.hideLoading();
|
||||||
if (isLogin) {
|
if (isLogin) {
|
||||||
uni.setStorageSync('phone', res.phone);
|
uni.setStorageSync('phone', res.phone);
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -134,6 +133,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
uni.hideLoading();
|
||||||
uni.removeStorageSync('ctoken');
|
uni.removeStorageSync('ctoken');
|
||||||
uni.removeStorageSync('userId');
|
uni.removeStorageSync('userId');
|
||||||
uni.removeStorageSync('openId');
|
uni.removeStorageSync('openId');
|
||||||
@ -148,14 +148,7 @@
|
|||||||
|
|
||||||
// app端登录
|
// app端登录
|
||||||
async appLogin() {
|
async appLogin() {
|
||||||
console.log('appLogin', this.userId);
|
|
||||||
console.log('passWord', this.passWord);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
uni.showLoading({
|
|
||||||
title: '登录中...',
|
|
||||||
mask: true
|
|
||||||
})
|
|
||||||
const loginRes = await request(apiArr.login, 'POST', {
|
const loginRes = await request(apiArr.login, 'POST', {
|
||||||
code: '',
|
code: '',
|
||||||
phone: this.userId,
|
phone: this.userId,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
139
unpackage/dist/dev/mp-weixin/pages/index/index.js
vendored
139
unpackage/dist/dev/mp-weixin/pages/index/index.js
vendored
@ -207,7 +207,6 @@ var _index2 = __webpack_require__(/*! ../../utils/index.js */ 167);
|
|||||||
var _community = __webpack_require__(/*! ../../api/community.js */ 168);
|
var _community = __webpack_require__(/*! ../../api/community.js */ 168);
|
||||||
var _doorToDoor = __webpack_require__(/*! ../../api/doorToDoor.js */ 169);
|
var _doorToDoor = __webpack_require__(/*! ../../api/doorToDoor.js */ 169);
|
||||||
var _area = __webpack_require__(/*! ../../api/area.js */ 170);
|
var _area = __webpack_require__(/*! ../../api/area.js */ 170);
|
||||||
var _components$data$onSh;
|
|
||||||
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
||||||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
||||||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
||||||
@ -217,7 +216,7 @@ var nav = function nav() {
|
|||||||
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
|
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
|
||||||
};
|
};
|
||||||
//1.导入组件
|
//1.导入组件
|
||||||
var _default = (_components$data$onSh = {
|
var _default = {
|
||||||
components: {
|
components: {
|
||||||
nav: nav
|
nav: nav
|
||||||
},
|
},
|
||||||
@ -295,15 +294,6 @@ var _default = (_components$data$onSh = {
|
|||||||
// },
|
// },
|
||||||
]), (0, _defineProperty2.default)(_ref, "title", 'Hello'), (0, _defineProperty2.default)(_ref, "currentCity", ""), (0, _defineProperty2.default)(_ref, "currentProviceCity", ""), _ref;
|
]), (0, _defineProperty2.default)(_ref, "title", 'Hello'), (0, _defineProperty2.default)(_ref, "currentCity", ""), (0, _defineProperty2.default)(_ref, "currentProviceCity", ""), _ref;
|
||||||
},
|
},
|
||||||
onShow: function onShow() {
|
|
||||||
if (uni.getStorageSync('city')) {
|
|
||||||
this.currentCity = {
|
|
||||||
city: uni.getStorageSync('city')
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
uni.setStorageSync('city', uni.getStorageSync('Usercity'));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
swipers: function swipers(e) {
|
swipers: function swipers(e) {
|
||||||
this.currentIdx = e.detail.current;
|
this.currentIdx = e.detail.current;
|
||||||
@ -354,7 +344,6 @@ var _default = (_components$data$onSh = {
|
|||||||
that.CommunityList = that.CommunityList.concat(res.rows || []);
|
that.CommunityList = that.CommunityList.concat(res.rows || []);
|
||||||
that.flag = flag;
|
that.flag = flag;
|
||||||
that.page_num = that.page_num + 1;
|
that.page_num = that.page_num + 1;
|
||||||
console.log(that.CommunityList);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getHostInfo: function getHostInfo() {
|
getHostInfo: function getHostInfo() {
|
||||||
@ -387,6 +376,12 @@ var _default = (_components$data$onSh = {
|
|||||||
if (idx == 0) {
|
if (idx == 0) {
|
||||||
this.getCommunityList();
|
this.getCommunityList();
|
||||||
} else if (idx == 1) {
|
} else if (idx == 1) {
|
||||||
|
if (!uni.getStorageSync('ctoken')) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/login/login'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.getServerList();
|
this.getServerList();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -471,7 +466,6 @@ var _default = (_components$data$onSh = {
|
|||||||
if (res.rows.length) {
|
if (res.rows.length) {
|
||||||
res.rows.forEach(function (item) {
|
res.rows.forEach(function (item) {
|
||||||
item.icon_src = _index2.picUrl + item.icon_src;
|
item.icon_src = _index2.picUrl + item.icon_src;
|
||||||
console.log(item.icon_src, 'banner1');
|
|
||||||
});
|
});
|
||||||
_this3.tabList = res.rows;
|
_this3.tabList = res.rows;
|
||||||
}
|
}
|
||||||
@ -573,7 +567,7 @@ var _default = (_components$data$onSh = {
|
|||||||
init: function init() {
|
init: function init() {
|
||||||
var _this4 = this;
|
var _this4 = this;
|
||||||
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
||||||
var _yield$Promise$all, _yield$Promise$all2, provRes, cityRes, distRes, cascaderOptions;
|
var proviceList, cityList, businessList, cascaderOptions, _yield$Promise$all, _yield$Promise$all2, provRes, cityRes, distRes;
|
||||||
return _regenerator.default.wrap(function _callee4$(_context4) {
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
||||||
while (1) {
|
while (1) {
|
||||||
switch (_context4.prev = _context4.next) {
|
switch (_context4.prev = _context4.next) {
|
||||||
@ -583,9 +577,17 @@ var _default = (_components$data$onSh = {
|
|||||||
mask: true
|
mask: true
|
||||||
});
|
});
|
||||||
_context4.prev = 1;
|
_context4.prev = 1;
|
||||||
_context4.next = 4;
|
proviceList = uni.getStorageSync('proviceList');
|
||||||
|
cityList = uni.getStorageSync('cityList');
|
||||||
|
businessList = uni.getStorageSync('businessList');
|
||||||
|
cascaderOptions = null; // 有缓存数据时 不进行接口请求
|
||||||
|
if (!(!proviceList || !cityList || !businessList)) {
|
||||||
|
_context4.next = 19;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_context4.next = 9;
|
||||||
return Promise.all([_this4.getProvList(), _this4.getCityList(), _this4.getDistList()]);
|
return Promise.all([_this4.getProvList(), _this4.getCityList(), _this4.getDistList()]);
|
||||||
case 4:
|
case 9:
|
||||||
_yield$Promise$all = _context4.sent;
|
_yield$Promise$all = _context4.sent;
|
||||||
_yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 3);
|
_yield$Promise$all2 = (0, _slicedToArray2.default)(_yield$Promise$all, 3);
|
||||||
provRes = _yield$Promise$all2[0];
|
provRes = _yield$Promise$all2[0];
|
||||||
@ -594,13 +596,13 @@ var _default = (_components$data$onSh = {
|
|||||||
uni.setStorageSync('proviceList', provRes.rows);
|
uni.setStorageSync('proviceList', provRes.rows);
|
||||||
uni.setStorageSync('cityList', cityRes.rows);
|
uni.setStorageSync('cityList', cityRes.rows);
|
||||||
uni.setStorageSync('businessList', distRes.rows);
|
uni.setStorageSync('businessList', distRes.rows);
|
||||||
cascaderOptions = provRes.rows.map(function (province) {
|
cascaderOptions = provRes === null || provRes === void 0 ? void 0 : provRes.rows.map(function (province) {
|
||||||
return {
|
return {
|
||||||
value: province.city_id,
|
value: province.city_id,
|
||||||
// 使用 city_id 作为省的值
|
// 使用 city_id 作为省的值
|
||||||
label: province.name,
|
label: province.name,
|
||||||
// 使用 name 作为省的显示文本
|
// 使用 name 作为省的显示文本
|
||||||
children: cityRes.rows.filter(function (city) {
|
children: cityRes === null || cityRes === void 0 ? void 0 : cityRes.rows.filter(function (city) {
|
||||||
return city.city_id === province.city_id;
|
return city.city_id === province.city_id;
|
||||||
}) // 注意:这里需要确认关联字段
|
}) // 注意:这里需要确认关联字段
|
||||||
.map(function (city) {
|
.map(function (city) {
|
||||||
@ -609,7 +611,7 @@ var _default = (_components$data$onSh = {
|
|||||||
// 使用 area_id 作为市的值
|
// 使用 area_id 作为市的值
|
||||||
label: city.area_name,
|
label: city.area_name,
|
||||||
// 使用 area_name 作为市的显示文本
|
// 使用 area_name 作为市的显示文本
|
||||||
children: distRes.rows.filter(function (district) {
|
children: distRes === null || distRes === void 0 ? void 0 : distRes.rows.filter(function (district) {
|
||||||
return district.area_id === city.area_id;
|
return district.area_id === city.area_id;
|
||||||
}) // 注意:这里需要确认关联字段
|
}) // 注意:这里需要确认关联字段
|
||||||
.map(function (district) {
|
.map(function (district) {
|
||||||
@ -624,28 +626,65 @@ var _default = (_components$data$onSh = {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(cascaderOptions, 'cascaderOptions');
|
console.log('接口返回数据处理 省市区', cascaderOptions);
|
||||||
_this4.currentProviceCity = _this4.getProvinceCityId(cascaderOptions, uni.getStorageSync('city'));
|
|
||||||
_context4.next = 17;
|
|
||||||
return _this4.getButtonList();
|
|
||||||
case 17:
|
|
||||||
_context4.next = 19;
|
|
||||||
return _this4.getBannerList();
|
|
||||||
case 19:
|
case 19:
|
||||||
uni.hideLoading();
|
;
|
||||||
|
|
||||||
|
// 如果读的接口返回数据,则不二次进行处理, 否则对缓存数据进行二次处理
|
||||||
|
if (!cascaderOptions) {
|
||||||
|
cascaderOptions = proviceList.map(function (province) {
|
||||||
|
return {
|
||||||
|
value: province.city_id,
|
||||||
|
// 使用 city_id 作为省的值
|
||||||
|
label: province.name,
|
||||||
|
// 使用 name 作为省的显示文本
|
||||||
|
children: cityList.filter(function (city) {
|
||||||
|
return city.city_id === province.city_id;
|
||||||
|
}) // 注意:这里需要确认关联字段
|
||||||
|
.map(function (city) {
|
||||||
|
return {
|
||||||
|
value: city.area_id,
|
||||||
|
// 使用 area_id 作为市的值
|
||||||
|
label: city.area_name,
|
||||||
|
// 使用 area_name 作为市的显示文本
|
||||||
|
children: businessList.filter(function (district) {
|
||||||
|
return district.area_id === city.area_id;
|
||||||
|
}) // 注意:这里需要确认关联字段
|
||||||
|
.map(function (district) {
|
||||||
|
return {
|
||||||
|
value: district.business_id,
|
||||||
|
// 使用 business_id 作为区的值
|
||||||
|
label: district.business_name // 使用 business_name 作为区的显示文本
|
||||||
|
};
|
||||||
|
})
|
||||||
|
};
|
||||||
|
})
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log('读缓存数据处理的省市区', cascaderOptions);
|
||||||
|
}
|
||||||
|
_this4.currentProviceCity = _this4.getProvinceCityId(cascaderOptions, uni.getStorageSync('city'));
|
||||||
|
_context4.next = 24;
|
||||||
|
return _this4.getButtonList();
|
||||||
|
case 24:
|
||||||
_context4.next = 26;
|
_context4.next = 26;
|
||||||
|
return _this4.getBannerList();
|
||||||
|
case 26:
|
||||||
|
uni.hideLoading();
|
||||||
|
_context4.next = 33;
|
||||||
break;
|
break;
|
||||||
case 22:
|
case 29:
|
||||||
_context4.prev = 22;
|
_context4.prev = 29;
|
||||||
_context4.t0 = _context4["catch"](1);
|
_context4.t0 = _context4["catch"](1);
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
console.log('获取省市区信息异常', _context4.t0);
|
console.log('获取省市区信息异常', _context4.t0);
|
||||||
case 26:
|
case 33:
|
||||||
case "end":
|
case "end":
|
||||||
return _context4.stop();
|
return _context4.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, _callee4, null, [[1, 22]]);
|
}, _callee4, null, [[1, 29]]);
|
||||||
}))();
|
}))();
|
||||||
},
|
},
|
||||||
getProvinceCityId: function getProvinceCityId(areaList, cityName) {
|
getProvinceCityId: function getProvinceCityId(areaList, cityName) {
|
||||||
@ -762,27 +801,29 @@ var _default = (_components$data$onSh = {
|
|||||||
this.getHostInfo();
|
this.getHostInfo();
|
||||||
var meun = (0, _index2.menuButtonInfo)();
|
var meun = (0, _index2.menuButtonInfo)();
|
||||||
this.top = meun.height + meun.top;
|
this.top = meun.height + meun.top;
|
||||||
}
|
},
|
||||||
}, (0, _defineProperty2.default)(_components$data$onSh, "onShow", function onShow() {
|
onShow: function onShow() {
|
||||||
if (uni.getStorageSync('city')) {
|
if (uni.getStorageSync('city')) {
|
||||||
var obj = {
|
var obj = {
|
||||||
city: uni.getStorageSync('city')
|
city: uni.getStorageSync('city')
|
||||||
};
|
};
|
||||||
this.currentCity = obj;
|
this.currentCity = obj;
|
||||||
} else {
|
} else {
|
||||||
uni.setStorageSync('city', uni.getStorageSync('Usercity'));
|
uni.setStorageSync('city', uni.getStorageSync('Usercity'));
|
||||||
}
|
|
||||||
}), (0, _defineProperty2.default)(_components$data$onSh, "onReachBottom", function onReachBottom() {
|
|
||||||
if (this.current == 0) {
|
|
||||||
if (this.flag) {
|
|
||||||
this.getCommunityList();
|
|
||||||
}
|
}
|
||||||
} else if (this.current == 1) {
|
},
|
||||||
if (this.flag) {
|
onReachBottom: function onReachBottom() {
|
||||||
this.getServerList();
|
if (this.current == 0) {
|
||||||
|
if (this.flag) {
|
||||||
|
this.getCommunityList();
|
||||||
|
}
|
||||||
|
} else if (this.current == 1) {
|
||||||
|
if (this.flag) {
|
||||||
|
this.getServerList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}), _components$data$onSh);
|
};
|
||||||
exports.default = _default;
|
exports.default = _default;
|
||||||
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"], __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/wx.js */ 1)["default"]))
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"], __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/wx.js */ 1)["default"]))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user