配置修改

This commit is contained in:
2026-07-13 16:33:09 +08:00
parent 9998f4651b
commit d1a15a4c42
15 changed files with 348 additions and 38 deletions

View File

@ -7,7 +7,7 @@ use app\admin\logic\user\LevelLogic;
use app\admin\logic\user\UserLogic;
use app\common\model\user\UserLevel;
use app\common\server\JsonServer;
use app\common\enum\ClientEnum;
use app\common\logic\RegionLogic;
use app\admin\validate\user\UserValidate;
use think\exception\ValidateException;
@ -65,7 +65,8 @@ class User extends AdminBase
return view('', [
'info' => $detail,
'tag_list' => json_encode(TagLogic::getTagList())
'tag_list' => json_encode(TagLogic::getTagList()),
'city_list' => RegionLogic::hotCity(),
]);
}

View File

@ -141,7 +141,7 @@ class UserLogic extends Logic
{
$field = [
'id', 'sn','nickname','avatar','mobile','sex','birthday','tag_ids',
'remark','user_money','user_growth','user_integral','earnings', 'disable'
'remark','user_money','user_growth','user_integral','earnings', 'disable', 'city_id'
];
$user = User::field($field)->where(['del' => 0, 'id' => $id])->findOrEmpty();
@ -170,6 +170,7 @@ class UserLogic extends Logic
'tag_ids' => $post['select'],
'remark' => $post['remark'],
'disable' => $post['disable'],
'city_id' => (int)($post['city_id'] ?? 0),
'update_time' => time()
];
User::update($data);

View File

@ -69,6 +69,18 @@
<input class="layui-input" value="{$info.birthday}" autocomplete="off" name="birthday" id="birthday" type="text" placeholder="请输入生日" >
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">所属城市</label>
<div class="layui-input-inline" style="width: 380px;">
<select name="city_id" lay-search>
<option value="0">上海总部(默认)</option>
{volist name="city_list" id="city"}
<option value="{$city.id}" {if $info.city_id == $city.id}selected{/if}>{$city.name}</option>
{/volist}
</select>
</div>
<div class="layui-form-mid layui-word-aux">码主人所属地区,扫码进入时将展示对应城市商城</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">会员标签</label>
<div class="layui-input-block" style="width: 380px;">

View File

@ -4,12 +4,13 @@ namespace app\api\controller;
use app\common\basics\Api;
use app\api\logic\IndexLogic;
use app\common\logic\ChatLogic;
use app\common\logic\CityLogic;
use app\common\logic\RegionLogic;
use app\common\server\JsonServer;
class Index extends Api
{
public $like_not_need_login = ['index','hotCity', 'indexCategory', 'config','copyright','city','geocoder'];
public $like_not_need_login = ['index','hotCity', 'indexCategory', 'config','copyright','city','geocoder','getEntryCity'];
// 首页
public function index()
@ -114,4 +115,18 @@ class Index extends Api
}
return JsonServer::success('',$result);
}
/**
* 小程序进入时获取应展示的城市商城
* 未扫码:上海总部;扫码:码主人所属城市
*/
public function getEntryCity()
{
$params = [
'invite_code' => $this->request->get('invite_code', ''),
'user_id' => $this->request->get('user_id/d', 0),
];
$data = CityLogic::getEntryCity($params);
return JsonServer::success('获取成功', $data);
}
}

View File

@ -51,8 +51,7 @@ class Shop extends Api
public function getShopCityInfo()
{
if($this->request->isGet()) {
$city_id = $this->request->get('city_id', 0);
$data = ShopLogic::getShopCityInfo($city_id, $this->user_id, input());
$data = ShopLogic::getShopCityInfo(0, $this->user_id, input());
return JsonServer::success('获取店铺信息成功', $data);
}else{
return JsonServer::error('请求类型错误');

View File

@ -46,8 +46,7 @@ class ShopGoodsCategory extends Api
public function getCityGoodsCategory()
{
if($this->request->isGet()) {
$city_id = $this->request->get('city_id', 0);
$data = ShopGoodsCategoryLogic::getCityGoodsCategory($city_id);
$data = ShopGoodsCategoryLogic::getCityGoodsCategory(0, input());
return JsonServer::success('获取店铺分类成功', $data);
}else{
return JsonServer::error('请求类型错误');

View File

@ -27,6 +27,7 @@ use app\common\model\distribution\Distribution;
use app\common\model\distribution\DistributionLevel;
use app\common\server\ConfigServer;
use app\common\model\user\UserDistribution;
use app\common\logic\CityLogic;
use app\common\model\user\User;
use app\common\model\distribution\DistributionMemberApply;
use app\common\model\distribution\DistributionOrderGoods;
@ -133,7 +134,11 @@ class DistributionLogic extends Logic
'update_time' => $time,
];
DistributionMemberApply::create($data);
User::where("id",$user_id)->update(['url'=>$url['data']['qr_code']]);
$userUpdate = ['url' => $url['data']['qr_code']];
if (!empty($post['city'])) {
$userUpdate['city_id'] = (int)$post['city'];
}
User::where("id", $user_id)->update($userUpdate);
$distribution = Distribution::where("user_id",$user_id)->find();
$defaultLevelId = DistributionLevel::where('is_default', 1)->value('id');
$data = [
@ -263,7 +268,7 @@ class DistributionLogic extends Logic
try {
Db::startTrans();
$firstLeader = User::field(['id', 'first_leader', 'second_leader', 'third_leader', 'ancestor_relation','user_integral'])
$firstLeader = User::field(['id', 'first_leader', 'second_leader', 'third_leader', 'ancestor_relation','user_integral', 'city_id'])
->where(['distribution_code' => $post['code']])
->findOrEmpty();
if($firstLeader->isEmpty()) {
@ -298,6 +303,12 @@ class DistributionLogic extends Logic
'update_time' => time()
];
// 扫码进入时继承码主人的所属城市
$ownerCityId = CityLogic::getUserCityId((int)$firstLeader['id']);
if ($ownerCityId > 0) {
$data['city_id'] = $ownerCityId;
}
// 更新当前用户的分销关系
User::where(['id' => $post['user_id']])->update($data);
@ -368,7 +379,7 @@ class DistributionLogic extends Logic
try {
Db::startTrans();
$firstLeader = User::field(['id', 'first_leader', 'second_leader', 'third_leader', 'ancestor_relation','user_integral'])
$firstLeader = User::field(['id', 'first_leader', 'second_leader', 'third_leader', 'ancestor_relation','user_integral', 'city_id'])
->where(['id' => $post['user_id']])
->findOrEmpty();
if($firstLeader->isEmpty()) {
@ -389,6 +400,11 @@ class DistributionLogic extends Logic
'update_time' => time()
];
$ownerCityId = CityLogic::getUserCityId((int)$firstLeader['id']);
if ($ownerCityId > 0) {
$data['city_id'] = $ownerCityId;
}
// 更新当前用户的分销关系
User::where(['id' => $user_id])->update($data);
//通知用户

View File

@ -2,6 +2,7 @@
namespace app\api\logic;
use app\common\basics\Logic;
use app\common\logic\CityLogic;
use app\common\model\shop\Shop;
use app\common\model\shop\ShopGoodsCategory;
@ -27,18 +28,21 @@ class ShopGoodsCategoryLogic extends Logic
return $data;
}
public static function getCityGoodsCategory($city_id)
public static function getCityGoodsCategory($city_id, $params = [])
{
$shop_msg = Shop::where("city_id",$city_id)
->where("is_run",1)
->where("is_freeze",0)
->where("del",0)
->find();
$c = "";
if($shop_msg == null){
$shopId = 1;
}else{
$shopId = $shop_msg['id'];
$entryCity = CityLogic::getEntryCity([
'invite_code' => $params['invite_code'] ?? '',
'user_id' => (int)($params['user_id'] ?? 0),
]);
$shopId = (int)($entryCity['shop_id'] ?? 0);
if ($shopId <= 0) {
$city_id = (int)($entryCity['id'] ?? 0);
$shop_msg = Shop::where("city_id", $city_id)
->where("is_run", 1)
->where("is_freeze", 0)
->where("del", 0)
->find();
$shopId = $shop_msg == null ? 1 : (int)$shop_msg['id'];
}
$where = [
'del' => 0,

View File

@ -5,6 +5,7 @@ use app\common\basics\Logic;
use app\common\enum\GoodsEnum;
use app\common\enum\ShopAdEnum;
use app\common\enum\ShopEnum;
use app\common\logic\CityLogic;
use app\common\logic\QrCodeLogic;
use app\common\model\dev\DevRegion;
use app\common\model\shop\ShopAd;
@ -108,21 +109,32 @@ class ShopLogic extends Logic
return $shop;
}
public static function getShopCityInfo($city_id,$userId, $params = [])
public static function getShopCityInfo($city_id, $userId, $params = [])
{
// 未扫码进入:上海总部;扫码进入:码主人所属城市(忽略定位 city_id
$entryCity = CityLogic::getEntryCity([
'invite_code' => $params['invite_code'] ?? '',
'user_id' => (int)($params['user_id'] ?? 0),
]);
$city_id = (int)($entryCity['id'] ?? 0);
$entryShopId = (int)($entryCity['shop_id'] ?? 0);
// 记录统计信息(访问商铺用户量)
Event::listen('ShopStat', 'app\common\listener\ShopStat');
$shop_msg = Shop::where("city_id",$city_id)
->where("is_run",1)
->where("is_freeze",0)
->where("del",0)
->find();
$c = "";
if($shop_msg == null){
$c = "id = 1";
}else{
$c = "city_id = ".$city_id."";
if ($entryShopId > 0) {
$c = 'id = ' . $entryShopId;
} else {
$shop_msg = Shop::where("city_id", $city_id)
->where("is_run", 1)
->where("is_freeze", 0)
->where("del", 0)
->find();
if ($shop_msg == null) {
$c = "id = 1";
} else {
$c = "city_id = " . $city_id . "";
}
}
$field = [
@ -199,6 +211,8 @@ class ShopLogic extends Logic
'mobile' => ShopAd::where($adWhere)->where('terminal', ShopAdEnum::TERMINAL_MOBILE)->append([ 'link_path', 'link_query' ])->order('sort desc,id desc')->select()->toArray(),
];
$shop['entry_city'] = $entryCity;
return $shop;
}

View File

@ -0,0 +1,178 @@
<?php
namespace app\common\logic;
use app\common\basics\Logic;
use app\common\model\DevRegion;
use app\common\model\distribution\DistributionMemberApply;
use app\common\model\shop\Shop;
use app\common\model\user\User;
use app\common\server\ConfigServer;
class CityLogic extends Logic
{
/**
* 根据进入方式获取应展示的城市商城
* 未扫码进入:上海总部;扫码进入:码主人所属城市
*/
public static function getEntryCity(array $params = []): array
{
if (!empty($params['invite_code'])) {
return self::getCityByInviteCode($params['invite_code']);
}
if (!empty($params['user_id'])) {
return self::getCityByUserId((int)$params['user_id']);
}
return self::getHeadquartersCity();
}
/**
* 上海总部城市(默认商城)
*/
public static function getHeadquartersCity(): array
{
$cityId = self::resolveHeadquartersCityId();
if ($cityId <= 0) {
return self::formatCityInfo(0, true);
}
return self::formatCityInfo($cityId, true);
}
/**
* 根据邀请码获取码主人所属城市
*/
public static function getCityByInviteCode(string $code): array
{
$user = User::where(['distribution_code' => $code, 'del' => 0])
->field('id,city_id')
->findOrEmpty();
if ($user->isEmpty()) {
return self::getHeadquartersCity();
}
$cityId = self::resolveUserCityId((int)$user['id'], (int)$user['city_id']);
if ($cityId <= 0) {
return self::getHeadquartersCity();
}
return self::formatCityInfo($cityId);
}
/**
* 根据用户ID获取所属城市分销扫码等场景
*/
public static function getCityByUserId(int $userId): array
{
$user = User::where(['id' => $userId, 'del' => 0])
->field('id,city_id')
->findOrEmpty();
if ($user->isEmpty()) {
return self::getHeadquartersCity();
}
$cityId = self::resolveUserCityId((int)$user['id'], (int)$user['city_id']);
if ($cityId <= 0) {
return self::getHeadquartersCity();
}
return self::formatCityInfo($cityId);
}
/**
* 解析用户所属城市:优先用户表,其次分销申请地区
*/
protected static function resolveUserCityId(int $userId, int $cityId = 0): int
{
if ($cityId > 0) {
return $cityId;
}
if ($userId <= 0) {
return 0;
}
return (int)DistributionMemberApply::where([
['user_id', '=', $userId],
['status', '=', 1],
])->order('id desc')->value('city');
}
/**
* 获取用户所属城市ID扫码绑定时继承上级地区
*/
public static function getUserCityId(int $userId): int
{
if ($userId <= 0) {
return 0;
}
$cityId = (int)User::where(['id' => $userId, 'del' => 0])->value('city_id');
return self::resolveUserCityId($userId, $cityId);
}
protected static function formatCityInfo(int $cityId, bool $isHeadquarters = false): array
{
if ($cityId <= 0) {
return [
'id' => 0,
'name' => '上海总部',
'gcj02_lat' => 0,
'gcj02_lng' => 0,
'shop_id' => 1,
'is_headquarters' => 1,
];
}
$city = DevRegion::where('id', $cityId)
->field('id,name,gcj02_lat,gcj02_lng,db09_lat,db09_lng')
->findOrEmpty();
if ($city->isEmpty()) {
return [
'id' => 0,
'name' => '上海总部',
'gcj02_lat' => 0,
'gcj02_lng' => 0,
'shop_id' => 1,
'is_headquarters' => 1,
];
}
$shop = Shop::where([
['city_id', '=', $cityId],
['is_run', '=', 1],
['is_freeze', '=', 0],
['del', '=', 0],
])->field('id')->findOrEmpty();
return [
'id' => (int)$city['id'],
'name' => $city['name'],
'gcj02_lat' => (float)($city['gcj02_lat'] ?: 0),
'gcj02_lng' => (float)($city['gcj02_lng'] ?: 0),
'shop_id' => $shop->isEmpty() ? 1 : (int)$shop['id'],
'is_headquarters' => $isHeadquarters ? 1 : 0,
];
}
protected static function resolveHeadquartersCityId(): int
{
$cityId = (int)ConfigServer::get('shop', 'headquarters_city_id', 0);
if ($cityId <= 0) {
$cityId = (int)Shop::where(['id' => 1, 'del' => 0])->value('city_id');
}
if ($cityId <= 0) {
$cityId = (int)DevRegion::where(['level' => 2])
->whereLike('name', '上海%')
->value('id');
}
return $cityId;
}
}

View File

@ -1 +1 @@
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["common/main"],{"0acf":function(e,t,n){"use strict";(function(e,t){var r=n("47a9"),o=r(n("7ca3"));n("3712");var c=r(n("3240")),a=r(n("568c")),u=r(n("31f5")),i=n("0aec"),f=r(n("3f13")),s=r(n("2a4c")),d=r(n("995a")),l=n("6495");function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){(0,o.default)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}e.__webpack_require_UNI_MP_PLUGIN__=n;c.default.component("mescroll-body",(function(){Promise.all([n.e("common/vendor"),n.e("components/mescroll-uni/mescroll-body")]).then(function(){return resolve(n("4c53"))}.bind(null,n)).catch(n.oe)})),c.default.prototype.$toast=i.toast,c.default.prototype.$Cache=f.default,c.default.config.productionTip=!1,c.default.component("RouterLink",(function(){n.e("js_sdk/uni-simple-router/link").then(function(){return resolve(n("898b"))}.bind(null,n)).catch(n.oe)})),c.default.use(l.router),c.default.mixin(d.default),c.default.use(s.default),a.default.mpType="app";var m=new c.default(b(b({},a.default),{},{store:u.default}));t(m).$mount()}).call(this,n("3223")["default"],n("df3c")["createApp"])},"568c":function(e,t,n){"use strict";n.r(t);var r=n("e4ad");for(var o in r)["default"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(o);n("dd8b");var c=n("828b"),a=Object(c["a"])(r["default"],void 0,void 0,!1,null,null,null,!1,void 0,void 0);t["default"]=a.exports},6864:function(e,t,n){},"80ef":function(e,t,n){"use strict";(function(e){var r=n("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(n("7eb4")),c=r(n("ee10")),a=r(n("7ca3")),u=n("8f59"),i=n("7a03"),f=n("0aec"),s=n("25af"),d=n("d0d1"),l=r(n("3f13"));function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){(0,a.default)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var m={onLaunch:function(e){this.getConfigFun(),this.getSystemInfo(),this.getUser(),this.checkMpUpdate()},onShow:function(e){console.log(e),this.bindCode(e)},onHide:function(){},computed:b({},(0,u.mapGetters)(["site_statistic"])),methods:b(b(b({},(0,u.mapActions)(["getSystemInfo","getUser","initLocationFunc"])),(0,u.mapMutations)(["setConfig"])),{},{getConfigFun:function(){var e=this;return(0,c.default)(o.default.mark((function t(){var n,r,c;return o.default.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,(0,i.getConfig)();case 2:n=t.sent,r=n.code,c=n.data,1==r&&e.setConfig(c);case 6:case"end":return t.stop()}}),t)})))()},bindCode:function(e){return(0,c.default)(o.default.mark((function t(){var n,r,c;return o.default.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e.query){t.next=2;break}return t.abrupt("return");case 2:if(n=e.query.invite_code||(0,f.strToParams)(decodeURIComponent(e.query.scene)).invite_code,!n){t.next=10;break}return t.next=6,(0,s.bindSuperior)({code:n});case 6:r=t.sent,r.data,c=r.code,-1==c&&l.default.set(d.INVITE_CODE,n);case 10:case"end":return t.stop()}}),t)})))()},checkMpUpdate:function(){var t=e.getUpdateManager();t.onUpdateReady((function(){e.showModal({title:"更新提示",content:"新版本已准备好,是否重启?",success:function(e){e.confirm&&t.applyUpdate()}})}))}})};t.default=m}).call(this,n("3223")["default"])},dd8b:function(e,t,n){"use strict";var r=n("6864"),o=n.n(r);o.a},e4ad:function(e,t,n){"use strict";n.r(t);var r=n("80ef"),o=n.n(r);for(var c in r)["default"].indexOf(c)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(c);t["default"]=o.a}},[["0acf","common/runtime","common/vendor"]]]);
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["common/main"],{"0acf":function(e,t,n){"use strict";(function(e,t){var r=n("47a9"),o=r(n("7ca3"));n("3712");var c=r(n("3240")),a=r(n("568c")),u=r(n("31f5")),i=n("0aec"),f=r(n("3f13")),s=r(n("2a4c")),d=r(n("995a")),l=n("6495");function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){(0,o.default)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}e.__webpack_require_UNI_MP_PLUGIN__=n;c.default.component("mescroll-body",(function(){Promise.all([n.e("common/vendor"),n.e("components/mescroll-uni/mescroll-body")]).then(function(){return resolve(n("4c53"))}.bind(null,n)).catch(n.oe)})),c.default.prototype.$toast=i.toast,c.default.prototype.$Cache=f.default,c.default.config.productionTip=!1,c.default.component("RouterLink",(function(){n.e("js_sdk/uni-simple-router/link").then(function(){return resolve(n("898b"))}.bind(null,n)).catch(n.oe)})),c.default.use(l.router),c.default.mixin(d.default),c.default.use(s.default),a.default.mpType="app";var m=new c.default(b(b({},a.default),{},{store:u.default}));t(m).$mount()}).call(this,n("3223")["default"],n("df3c")["createApp"])},"568c":function(e,t,n){"use strict";n.r(t);var r=n("e4ad");for(var o in r)["default"].indexOf(o)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(o);n("dd8b");var c=n("828b"),a=Object(c["a"])(r["default"],void 0,void 0,!1,null,null,null,!1,void 0,void 0);t["default"]=a.exports},6864:function(e,t,n){},"80ef":function(e,t,n){"use strict";(function(e){var r=n("47a9");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(n("7eb4")),c=r(n("ee10")),a=r(n("7ca3")),u=n("8f59"),i=n("7a03"),f=n("0aec"),s=n("25af"),d=n("d0d1"),l=r(n("3f13"));function p(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){(0,a.default)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var m={onLaunch:function(e){this.initEntryCityFun(e),this.getConfigFun(),this.getSystemInfo(),this.getUser(),this.checkMpUpdate()},onShow:function(e){console.log(e),this.bindCode(e)},onHide:function(){},computed:b({},(0,u.mapGetters)(["site_statistic"])),methods:b(b(b({},(0,u.mapActions)(["getSystemInfo","getUser","initLocationFunc"])),(0,u.mapMutations)(["setConfig","setCityInfo"])),{},{initEntryCityFun:function(t){var n={};if(t&&t.query){t.query.invite_code&&(n.invite_code=t.query.invite_code);if(t.query.scene){var r=(0,f.strToParams)(decodeURIComponent(t.query.scene));r.invite_code&&(n.invite_code=r.invite_code);r.user_id&&(n.user_id=r.user_id)}t.query.user_id&&(n.user_id=t.query.user_id)}e.setStorageSync("ENTRY_CITY_PARAMS",JSON.stringify(n));this.initLocationFunc()},getConfigFun:function(){var e=this;return(0,c.default)(o.default.mark((function t(){var n,r,c;return o.default.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,(0,i.getConfig)();case 2:n=t.sent,r=n.code,c=n.data,1==r&&e.setConfig(c);case 6:case"end":return t.stop()}}),t)})))()},bindCode:function(e){return(0,c.default)(o.default.mark((function t(){var n,r,c;return o.default.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e.query){t.next=2;break}return t.abrupt("return");case 2:if(n=e.query.invite_code||(0,f.strToParams)(decodeURIComponent(e.query.scene)).invite_code,!n){t.next=10;break}return t.next=6,(0,s.bindSuperior)({code:n});case 6:r=t.sent,r.data,c=r.code,-1==c&&l.default.set(d.INVITE_CODE,n);case 10:case"end":return t.stop()}}),t)})))()},checkMpUpdate:function(){var t=e.getUpdateManager();t.onUpdateReady((function(){e.showModal({title:"更新提示",content:"新版本已准备好,是否重启?",success:function(e){e.confirm&&t.applyUpdate()}})}))}})};t.default=m}).call(this,n("3223")["default"])},dd8b:function(e,t,n){"use strict";var r=n("6864"),o=n.n(r);o.a},e4ad:function(e,t,n){"use strict";n.r(t);var r=n("80ef"),o=n.n(r);for(var c in r)["default"].indexOf(c)<0&&function(e){n.d(t,e,(function(){return r[e]}))}(c);t["default"]=o.a}},[["0acf","common/runtime","common/vendor"]]]);

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/privacy-popup/privacy-popup"],{"0f76":function(t,n,e){"use strict";e.r(n);var o=e("f57b"),r=e.n(o);for(var c in o)["default"].indexOf(c)<0&&function(t){e.d(n,t,(function(){return o[t]}))}(c);n["default"]=r.a},5885:function(t,n,e){},"5d09":function(t,n,e){"use strict";var o=e("5885"),r=e.n(o);r.a},8561:function(t,n,e){"use strict";e.r(n);var o=e("e521"),r=e("0f76");for(var c in r)["default"].indexOf(c)<0&&function(t){e.d(n,t,(function(){return r[t]}))}(c);e("5d09");var u=e("828b"),i=Object(u["a"])(r["default"],o["b"],o["c"],!1,null,null,null,!1,o["a"],void 0);n["default"]=i.exports},e521:function(t,n,e){"use strict";e.d(n,"b",(function(){return r})),e.d(n,"c",(function(){return c})),e.d(n,"a",(function(){return o}));var o={uPopup:function(){return e.e("components/uview-ui/components/u-popup/u-popup").then(e.bind(null,"b12c"))}},r=function(){var t=this.$createElement;this._self._c},c=[]},f57b:function(t,n,e){"use strict";(function(t){var o=e("47a9");Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=o(e("7ca3")),c=e("8f59");function u(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,o)}return e}function i(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?u(Object(e),!0).forEach((function(n){(0,r.default)(t,n,e[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):u(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}))}return t}var a={props:{value:{type:Boolean,default:!1}},data:function(){return{}},computed:i({},(0,c.mapGetters)(["appConfig"])),methods:i(i({},(0,c.mapActions)(["initLocationFunc"])),{},{handleOpen:function(){t.openPrivacyContract({success:function(t){console.log(t)},fail:function(t){console.log(t)}})},handlecancel:function(){this.$toast({title:"须同意后才可继续使用"})},handleAgreePrivacyAuthorization:function(){this.$emit("input",!1),this.appConfig.is_open_nearby&&this.initLocationFunc()}})};n.default=a}).call(this,e("3223")["default"])}}]);
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/privacy-popup/privacy-popup"],{"0f76":function(t,n,e){"use strict";e.r(n);var o=e("f57b"),r=e.n(o);for(var c in o)["default"].indexOf(c)<0&&function(t){e.d(n,t,(function(){return o[t]}))}(c);n["default"]=r.a},5885:function(t,n,e){},"5d09":function(t,n,e){"use strict";var o=e("5885"),r=e.n(o);r.a},8561:function(t,n,e){"use strict";e.r(n);var o=e("e521"),r=e("0f76");for(var c in r)["default"].indexOf(c)<0&&function(t){e.d(n,t,(function(){return r[t]}))}(c);e("5d09");var u=e("828b"),i=Object(u["a"])(r["default"],o["b"],o["c"],!1,null,null,null,!1,o["a"],void 0);n["default"]=i.exports},e521:function(t,n,e){"use strict";e.d(n,"b",(function(){return r})),e.d(n,"c",(function(){return c})),e.d(n,"a",(function(){return o}));var o={uPopup:function(){return e.e("components/uview-ui/components/u-popup/u-popup").then(e.bind(null,"b12c"))}},r=function(){var t=this.$createElement;this._self._c},c=[]},f57b:function(t,n,e){"use strict";(function(t){var o=e("47a9");Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=o(e("7ca3")),c=e("8f59");function u(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,o)}return e}function i(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?u(Object(e),!0).forEach((function(n){(0,r.default)(t,n,e[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):u(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}))}return t}var a={props:{value:{type:Boolean,default:!1}},data:function(){return{}},computed:i({},(0,c.mapGetters)(["appConfig"])),methods:i(i({},(0,c.mapActions)(["initLocationFunc"])),{},{handleOpen:function(){t.openPrivacyContract({success:function(t){console.log(t)},fail:function(t){console.log(t)}})},handlecancel:function(){this.$toast({title:"须同意后才可继续使用"})},handleAgreePrivacyAuthorization:function(){this.$emit("input",!1),this.initLocationFunc()}})};n.default=a}).call(this,e("3223")["default"])}}]);
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
'components/privacy-popup/privacy-popup-create-component',
{

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,71 @@
/**
* 茶址商城:小程序入口城市逻辑补丁
* 将定位切换城市改为:直达=上海总部,扫码=码主人城市
*/
const fs = require('fs');
const path = require('path');
const root = path.join(__dirname, '..');
function patch(file, replacements) {
const filePath = path.join(root, file);
let content = fs.readFileSync(filePath, 'utf8');
let changed = 0;
for (const [oldStr, newStr] of replacements) {
if (!content.includes(oldStr)) {
console.error(`[MISS] ${file}: pattern not found`);
console.error(oldStr.slice(0, 120) + '...');
continue;
}
content = content.replace(oldStr, newStr);
changed++;
}
fs.writeFileSync(filePath, content, 'utf8');
console.log(`[OK] ${file}: ${changed} replacements`);
}
// 1. vendor.js - 新增 getEntryCity API
patch('public/mp-weixin/common/vendor.js', [
[
't.getGeocoder=function(e){return n.default.get("index/geocoder",{params:e})}',
't.getGeocoder=function(e){return n.default.get("index/geocoder",{params:e})},t.getEntryCity=function(e){return n.default.get("index/getEntryCity",{params:e})}'
],
[
'initLocationFunc:function(t){return(0,i.default)(n.default.mark((function a(){var l,r,i,u,s,c;return n.default.wrap((function(a){while(1)switch(a.prev=a.next){case 0:return l=t.dispatch,r=t.rootState,console.log("获取地址"),a.prev=2,a.next=5,e.getLocation({type:"gcj02"});case 5:if(i=a.sent,u=(0,o.default)(i,2),s=u[0],c=u[1],console.log(s,c,"----"),l("getSystemInfo"),r.app.sysInfo.locationEnabled){a.next=14;break}return e.showModal({title:"温馨提示",content:"您的手机定位还未开启"}),a.abrupt("return");case 14:if(c){a.next=16;break}return a.abrupt("return",l("getAuthorize"));case 16:if(!s){a.next=19;break}return e.showModal({title:"温馨提示",content:"获取位置失败,请检查是否开启定位!"}),a.abrupt("return");case 19:l("getGeocoderFunc",{location:"".concat(c.latitude,",").concat(c.longitude)}),a.next=25;break;case 22:a.prev=22,a.t0=a["catch"](2),console.log(a.t0);case 25:case"end":return a.stop()}}),a,null,[[2,22]])})))()}',
'initLocationFunc:function(t){return(0,i.default)(n.default.mark((function a(){var l,r,u,c,v;return n.default.wrap((function(a){while(1)switch(a.prev=a.next){case 0:return l=t.commit,a.prev=1,u={},a.prev=2,c=e.getStorageSync("ENTRY_CITY_PARAMS"),c&&(u=JSON.parse(c)),a.next=7,(0,s.getEntryCity)(u);case 7:if(v=a.sent,1!=v.code){a.next=11;break}r=v.data,l("setCityInfo",{id:r.id,name:r.name,gcj02_lat:r.gcj02_lat||0,gcj02_lng:r.gcj02_lng||0}),a.next=12;break;case 11:l("setCityInfo",{id:0,name:"上海总部",gcj02_lat:0,gcj02_lng:0});case 12:a.next=17;break;case 14:a.prev=14,a.t0=a["catch"](2),console.log(a.t0),l("setCityInfo",{id:0,name:"上海总部",gcj02_lat:0,gcj02_lng:0});case 17:case"end":return a.stop()}}),a,null,[[2,14],[1,14]])})))()}'
]
]);
// 2. main.js - onLaunch 解析扫码参数并初始化城市
patch('public/mp-weixin/common/main.js', [
[
'onLaunch:function(e){this.getConfigFun(),this.getSystemInfo(),this.getUser(),this.checkMpUpdate()}',
'onLaunch:function(e){this.initEntryCityFun(e),this.getConfigFun(),this.getSystemInfo(),this.getUser(),this.checkMpUpdate()}'
],
[
'(0,u.mapActions)(["getSystemInfo","getUser","initLocationFunc"])),(0,u.mapMutations)(["setConfig"])',
'(0,u.mapActions)(["getSystemInfo","getUser","initLocationFunc"])),(0,u.mapMutations)(["setConfig","setCityInfo"])'
],
[
'getConfigFun:function(){var e=this;return(0,c.default)(o.default.mark((function t(){var n,r,c;return o.default.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,(0,i.getConfig)();',
'initEntryCityFun:function(t){var n={};if(t&&t.query){t.query.invite_code&&(n.invite_code=t.query.invite_code);if(t.query.scene){var r=(0,f.strToParams)(decodeURIComponent(t.query.scene));r.invite_code&&(n.invite_code=r.invite_code);r.user_id&&(n.user_id=r.user_id)}t.query.user_id&&(n.user_id=t.query.user_id)}e.setStorageSync("ENTRY_CITY_PARAMS",JSON.stringify(n));this.initLocationFunc()},getConfigFun:function(){var e=this;return(0,c.default)(o.default.mark((function t(){var n,r,c;return o.default.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,(0,i.getConfig)();'
]
]);
// 3. privacy-popup.js - 同意隐私协议后初始化城市(不再依赖定位开关)
patch('public/mp-weixin/components/privacy-popup/privacy-popup.js', [
[
'handleAgreePrivacyAuthorization:function(){this.$emit("input",!1),this.appConfig.is_open_nearby&&this.initLocationFunc()}',
'handleAgreePrivacyAuthorization:function(){this.$emit("input",!1),this.initLocationFunc()}'
]
]);
// 4. index.js - 网络重试时初始化城市(不再走定位)
patch('public/mp-weixin/pages/index/index.js', [
[
'1==o&&(e.setConfig(r),r.is_open_nearby&&e.initLocationFunc()),e.getUser()',
'1==o&&(e.setConfig(r),e.initLocationFunc()),e.getUser()'
]
]);
console.log('Patch complete.');