jmash-core-mp 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ export interface AppConfig {
14
14
  siteId: string;
15
15
  dev: boolean;
16
16
  testNewUser: boolean;
17
+ [key: string]: any;
17
18
  }
18
19
  export interface ValidateData {
19
20
  validate: boolean;
package/lib/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export type { FileInfo, FileBase64Req, FileDownInfo, FileWebReq, } from "./api/f
7
7
  export type { DictRegionList, DictRegionReq, DictRegionModel, } from "./api/region/types";
8
8
  export type { StorageOrganInfoReq, StorageOrganInfoList, StorageOrganInfoModel, ShopBrowserUserList, ShopBrowserUserModel, StorageOrganBrowserUpdateReq, StorageOrganBrowserModel, } from "./api/storage/types";
9
9
  export { mpxFetch } from "./utils/request";
10
- export { config } from "./utils/config";
10
+ export { config, initConfig, setConfig } from "./utils/config";
11
11
  export { grpc } from "./utils/grpc";
12
12
  export { db } from "./utils/db";
13
13
  export { useUserStore } from "./store/user";
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { EntryDict, EnumDict } from "./api/dicts";
2
2
  export { mpxFetch } from "./utils/request";
3
- export { config } from "./utils/config";
3
+ export { config, initConfig, setConfig } from "./utils/config";
4
4
  export { grpc } from "./utils/grpc";
5
5
  export { db } from "./utils/db";
6
6
  export { useUserStore } from "./store/user";
@@ -1,3 +1,5 @@
1
1
  import { AppConfig } from "../api/types";
2
2
  declare const config: AppConfig;
3
- export { config };
3
+ declare function setConfig(cfg: Partial<AppConfig>): void;
4
+ declare function initConfig(config: Partial<AppConfig>, mode: string): Partial<AppConfig>;
5
+ export { config, setConfig, initConfig };
@@ -1,4 +1,5 @@
1
- const config = {
1
+ import mpx from "@mpxjs/core";
2
+ const defaultConfig = {
2
3
  name: "Jmash Core MPX",
3
4
  dev: true,
4
5
  testNewUser: false,
@@ -12,19 +13,17 @@ const config = {
12
13
  wechatBiz: "",
13
14
  siteId: "c0a28f0f-023a-420b-b4e8-0ce138ac8269",
14
15
  };
15
- if (__mpx_mode__ === "wx") {
16
- // 微信
17
- config.appId = "wx2a8b3d689b8959eb1";
16
+ const config = { ...defaultConfig };
17
+ function setConfig(cfg) {
18
+ Object.assign(config, cfg);
18
19
  }
19
- else if (__mpx_mode__ === "ali") {
20
- // 支付宝
21
- config.appId = "2016102700684542";
20
+ function initConfig(config, mode) {
21
+ if (__mpx_mode__ !== "web") {
22
+ // 只有运行时才能调用
23
+ const accountInfo = mpx.getAccountInfoSync();
24
+ // 微信
25
+ config.appId = accountInfo.miniProgram.appId;
26
+ }
27
+ return config;
22
28
  }
23
- else if (__mpx_mode__ === "web") {
24
- // Web
25
- config.appId = "web";
26
- }
27
- else {
28
- // 执行其他环境相关逻辑
29
- }
30
- export { config };
29
+ export { config, setConfig, initConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "private": false,
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/api/types.ts CHANGED
@@ -30,6 +30,8 @@ export interface AppConfig {
30
30
  dev: boolean;
31
31
  //是否测试新用户.
32
32
  testNewUser: boolean;
33
+ // 其他配置项
34
+ [key: string]: any;
33
35
  }
34
36
 
35
37
  // 校验
package/src/app.mpx CHANGED
@@ -7,20 +7,18 @@ mpx.use(apiProxy, { usePromise: true })
7
7
  import { createPinia } from '@mpxjs/pinia';
8
8
  createPinia();
9
9
  //网络请求和App配置
10
- import { mpxFetch, config } from "./index";
10
+ import { mpxFetch, config, initConfig } from "./index";
11
11
  mpx.use(mpxFetch);
12
12
 
13
13
  createApp({
14
+ onLaunch(options) {
15
+ initConfig(config, "dev");
16
+ console.log("config", config);
17
+ },
14
18
  globalData: {
15
19
  config: config
16
20
  }
17
21
  })
18
- if (__mpx_mode__ !== "web") {
19
- // 只有运行时才能调用
20
- const accountInfo = mpx.getAccountInfoSync();
21
- // 微信
22
- config.appId = accountInfo.miniProgram.appId;
23
- }
24
22
  </script>
25
23
 
26
24
  <style></style>
@@ -6,7 +6,7 @@
6
6
  <view class="main-profile" wx:if="{{ isUserAvatar }}">
7
7
  <view class="profile-left">头像</view>
8
8
  <view class="profile-right">
9
- <button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar@wx="onChooseAvatar"
9
+ <button class="avatar-wrapper" plain open-type="chooseAvatar" bind:chooseavatar@wx="onChooseAvatar"
10
10
  onChooseAvatar@ali="onChooseAvatar">
11
11
  <image class="avatar-img" src="{{ resourceUrl + '/components/gray_head2x.png' }}" mode="aspectFill"
12
12
  wx:if="{{ !userInfo.avatar }}" />
@@ -259,8 +259,12 @@ $bg-card: #ffffff;
259
259
  margin: 0;
260
260
  padding: 0;
261
261
  background: transparent;
262
- border: none;
263
262
  line-height: 1;
263
+ border: 0;
264
+
265
+ &::after {
266
+ display: none;
267
+ }
264
268
 
265
269
  .avatar-img {
266
270
  width: 88rpx;
@@ -1,17 +1,16 @@
1
1
  <template>
2
2
  <view class="auth-user-box">
3
3
  <block wx:if="{{ isLogin }}">
4
- <view class="auth-user-l">
4
+ <view class="auth-user-l" bind:tap="handleUpdateUser">
5
5
  <!-- 头像 -->
6
6
  <view class="avatar-wrapper">
7
7
  <image src="{{ baseUrl+'/v1/file/image/clip/200/200/' + userInfo.avatar }}" class="avatar-img"
8
8
  wx:if="{{ userInfo.avatar }}" mode="aspectFill"></image>
9
- <image src="{{ resourceUrl + '/images/mall/' + defaultAvatar }}" class="avatar-img"
10
- wx:elif="{{ defaultAvatar }}" mode="aspectFill"></image>
9
+ <image src="{{ defaultAvatar }}" class="avatar-img" wx:elif="{{ defaultAvatar }}" mode="aspectFill"></image>
11
10
  <image src="{{ resourceUrl }}/images/mall/tswk.png" class="avatar-img" wx:else mode="aspectFill"></image>
12
- <view class="avatar-badge">
11
+ <!-- <view class="avatar-badge">
13
12
  <text class="badge-icon">✎</text>
14
- </view>
13
+ </view> -->
15
14
  </view>
16
15
 
17
16
  <!-- 用户信息 -->
@@ -27,9 +26,9 @@
27
26
  </view>
28
27
 
29
28
  <!-- 右侧箭头 -->
30
- <view class="right-arrow" bind:tap="handleUpdateUser">
29
+ <!-- <view class="right-arrow" bind:tap="handleUpdateUser">
31
30
  <text class="arrow-icon">›</text>
32
- </view>
31
+ </view> -->
33
32
  </view>
34
33
  </block>
35
34
 
@@ -37,7 +36,11 @@
37
36
  <view class="auth-user-l not-logged-in" wx:else>
38
37
  <view class="not-logged-wrapper">
39
38
  <view class="avatar-wrapper" bind:tap="handleLogin">
40
- <image src="{{ resourceUrl }}/images/mall/tswk.png" class="avatar-img not-logged" mode="aspectFill"></image>
39
+ <!-- <image src="{{ resourceUrl }}/images/mall/tswk.png" class="avatar-img not-logged" mode="aspectFill"></image> -->
40
+ <image src="{{ defaultAvatar }}" class="avatar-img not-logged" wx:if="{{ defaultAvatar }}" mode="aspectFill">
41
+ </image>
42
+ <image src="{{ resourceUrl }}/images/mall/tswk.png" class="avatar-img not-logged" wx:else mode="aspectFill">
43
+ </image>
41
44
  <view class="avatar-plus">
42
45
  <text class="plus-icon">+</text>
43
46
  </view>
@@ -171,11 +174,11 @@ $bg-card: #ffffff;
171
174
  width: 130rpx;
172
175
  height: 130rpx;
173
176
  border-radius: 50%;
174
- background-color: $bg-page;
177
+ // background-color: $bg-page;
175
178
  display: block;
176
179
  transition: all 0.3s;
177
- border: 3rpx solid rgba(7, 193, 96, 0.1);
178
- box-shadow: 0 4rpx 12rpx rgba(7, 193, 96, 0.1);
180
+ // border: 3rpx solid rgba(7, 193, 96, 0.1);
181
+ // box-shadow: 0 4rpx 12rpx rgba(7, 193, 96, 0.1);
179
182
 
180
183
  &:active {
181
184
  transform: scale(1.05);
@@ -228,9 +231,9 @@ $bg-card: #ffffff;
228
231
  }
229
232
 
230
233
  .edit-icon-bg {
231
- width: 32rpx;
232
- height: 32rpx;
233
- background: rgba(7, 193, 96, 0.1);
234
+ width: 36rpx;
235
+ height: 36rpx;
236
+ background: $primary;
234
237
  border-radius: 50%;
235
238
  display: flex;
236
239
  align-items: center;
@@ -238,8 +241,8 @@ $bg-card: #ffffff;
238
241
  margin-left: 8rpx;
239
242
 
240
243
  .edit-icon {
241
- font-size: 14rpx;
242
- color: $primary;
244
+ font-size: 16rpx;
245
+ color: #fff;
243
246
  }
244
247
  }
245
248
  }
@@ -12,11 +12,11 @@
12
12
 
13
13
  <script lang="ts">
14
14
  import mpx, { createComponent, ref } from "@mpxjs/core"
15
- import { config } from "../../utils/config";
16
15
  import { EventBase } from "../../api/types";
17
16
 
18
17
  createComponent({
19
18
  setup() {
19
+ let config = getApp().globalData.config;
20
20
  // 静态图片资源
21
21
  let imageUrl = config.baseUrl + "/v1/file/image/clip/750/750/"
22
22
  // 接口资源路径
package/src/index.ts CHANGED
@@ -52,7 +52,7 @@ export type {
52
52
  } from "./api/storage/types";
53
53
 
54
54
  export { mpxFetch } from "./utils/request";
55
- export { config } from "./utils/config";
55
+ export { config, initConfig, setConfig } from "./utils/config";
56
56
  export { grpc } from "./utils/grpc";
57
57
  export { db } from "./utils/db";
58
58
  export { useUserStore } from "./store/user";
@@ -1,6 +1,7 @@
1
1
  import { AppConfig } from "../api/types";
2
+ import mpx from "@mpxjs/core";
2
3
 
3
- const config: AppConfig = {
4
+ const defaultConfig: AppConfig = {
4
5
  name: "Jmash Core MPX",
5
6
  dev: true,
6
7
  testNewUser: false,
@@ -15,17 +16,20 @@ const config: AppConfig = {
15
16
  siteId: "c0a28f0f-023a-420b-b4e8-0ce138ac8269",
16
17
  };
17
18
 
18
- if (__mpx_mode__ === "wx") {
19
- // 微信
20
- config.appId = "wx2a8b3d689b8959eb1";
21
- } else if (__mpx_mode__ === "ali") {
22
- // 支付宝
23
- config.appId = "2016102700684542";
24
- } else if (__mpx_mode__ === "web") {
25
- // Web
26
- config.appId = "web";
27
- } else {
28
- // 执行其他环境相关逻辑
19
+ const config: AppConfig = { ...defaultConfig };
20
+
21
+ function setConfig(cfg: Partial<AppConfig>) {
22
+ Object.assign(config, cfg);
23
+ }
24
+
25
+ function initConfig(config: Partial<AppConfig>, mode: string) {
26
+ if (__mpx_mode__ !== "web") {
27
+ // 只有运行时才能调用
28
+ const accountInfo = mpx.getAccountInfoSync();
29
+ // 微信
30
+ config.appId = accountInfo.miniProgram.appId;
31
+ }
32
+ return config;
29
33
  }
30
34
 
31
- export { config };
35
+ export { config, setConfig, initConfig };