jmash-core-mp 0.1.27 → 0.1.29

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.
@@ -0,0 +1 @@
1
+ export {};
package/lib/store/user.js CHANGED
@@ -115,7 +115,6 @@ export const useUserStore = defineStore("user", {
115
115
  },
116
116
  // 登录处理
117
117
  loginProcess(resp) {
118
- //console.log("miniappLogin", resp);
119
118
  if (resp.statusCode === 200 && resp.data.status === true) {
120
119
  console.log("login success");
121
120
  this.loginSuccess(resp.data.token);
@@ -151,7 +151,6 @@ export const validateRules = (value, message, rules) => {
151
151
  * @param {string} message 错误提示信息
152
152
  */
153
153
  export const validateRequired = (value, message) => {
154
- console.log(value, message);
155
154
  const valueStr = typeof value === "number" ? String(value) : value;
156
155
  if (!valueStr || valueStr.trim() === "") {
157
156
  // 显示错误提示
@@ -12,7 +12,6 @@ mpx.xfetch.interceptors.request.use(function (config) {
12
12
  const appconfig = getApp().globalData.config;
13
13
  config.url = appconfig.baseUrl + config.url;
14
14
  }
15
- //console.log("request:", config);
16
15
  // Grpc Gateway 清理默认值,Enum,时间等不能空;
17
16
  grpc.clearEmpty(config.params);
18
17
  grpc.clearEmpty(config.data);
@@ -43,7 +42,6 @@ mpx.xfetch.interceptors.request.use(function (config) {
43
42
  else {
44
43
  delete config.header["Grpc-Metadata-Tenant"];
45
44
  }
46
- //console.log("header:", config.header);
47
45
  }
48
46
  else if (!db.getRefreshToken()) {
49
47
  console.log("not token request. ");
@@ -86,7 +84,6 @@ mpx.xfetch.interceptors.request.use(function (config) {
86
84
  return config;
87
85
  });
88
86
  mpx.xfetch.interceptors.response.use(function (res) {
89
- // console.log(“response:”,res);
90
87
  if (res.statusCode === 200) {
91
88
  return res;
92
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "private": false,
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/app.mpx CHANGED
@@ -1,12 +1,12 @@
1
1
  <script lang="ts">
2
2
  import mpx, { createApp } from '@mpxjs/core';
3
- //api代理
3
+ // api代理
4
4
  import apiProxy from '@mpxjs/api-proxy';
5
5
  mpx.use(apiProxy, { usePromise: true })
6
- //状态管理
6
+ // 状态管理
7
7
  import { createPinia } from '@mpxjs/pinia';
8
8
  createPinia();
9
- //网络请求和App配置
9
+ // 网络请求和App配置
10
10
  import { mpxFetch, config, initConfig } from "./index";
11
11
  mpx.use(mpxFetch);
12
12
 
@@ -58,14 +58,3 @@ createApp({
58
58
  }
59
59
  }
60
60
  </script>
61
-
62
- <!--也可以通过以下形式用js输出json,便于书写注释和使用条件编译-->
63
-
64
- <!--<script name="json">-->
65
- <!-- // 可以写注释,通过defs注入的常量做一些判断之类的操作-->
66
- <!-- module.exports = {-->
67
- <!-- pages: [-->
68
- <!-- './pages/index'-->
69
- <!-- ]-->
70
- <!-- }-->
71
- <!--</script>-->
@@ -33,7 +33,8 @@ createComponent({
33
33
  content: '确定要退出登录吗?',
34
34
  success: (res) => {
35
35
  if (res.confirm) {
36
- this.userStore.logout() // 调用退出接口
36
+ // 调用退出接口
37
+ this.userStore.logout()
37
38
  mpx.showToast({ title: '已退出登录', icon: 'success' })
38
39
  // 通知父组件退出成功
39
40
  this.triggerEvent('logoutSuccess');
@@ -50,7 +51,8 @@ $primary: #07c160;
50
51
  $text-3: #999999;
51
52
 
52
53
  .logout-section {
53
- padding: 40rpx 16rpx 80rpx; // 底部留空适配tabbar
54
+ // 底部留空适配tabbar
55
+ padding: 40rpx 16rpx 80rpx;
54
56
  display: flex;
55
57
  flex-direction: column;
56
58
  align-items: center;
@@ -8,9 +8,6 @@
8
8
  wx:if="{{ userInfo.avatar }}" mode="aspectFill"></image>
9
9
  <image src="{{ defaultAvatar }}" class="avatar-img" wx:elif="{{ defaultAvatar }}" mode="aspectFill"></image>
10
10
  <image src="{{ resourceUrl }}/images/mall/tswk.png" class="avatar-img" wx:else mode="aspectFill"></image>
11
- <!-- <view class="avatar-badge">
12
- <text class="badge-icon">✎</text>
13
- </view> -->
14
11
  </view>
15
12
 
16
13
  <!-- 用户信息 -->
@@ -22,13 +19,8 @@
22
19
  </view>
23
20
  </view>
24
21
  <text class="user-mobile" style="color: {{ userMobileColor }}">{{ userInfo.mobilePhoneIns || '未绑定手机号'
25
- }}</text>
22
+ }}</text>
26
23
  </view>
27
-
28
- <!-- 右侧箭头 -->
29
- <!-- <view class="right-arrow" bind:tap="handleUpdateUser">
30
- <text class="arrow-icon">›</text>
31
- </view> -->
32
24
  </view>
33
25
  </block>
34
26
 
@@ -36,7 +28,6 @@
36
28
  <view class="auth-user-l not-logged-in" wx:else>
37
29
  <view class="not-logged-wrapper">
38
30
  <view class="avatar-wrapper" bind:tap="handleLogin">
39
- <!-- <image src="{{ resourceUrl }}/images/mall/tswk.png" class="avatar-img not-logged" mode="aspectFill"></image> -->
40
31
  <image src="{{ defaultAvatar }}" class="avatar-img not-logged" wx:if="{{ defaultAvatar }}" mode="aspectFill">
41
32
  </image>
42
33
  <image src="{{ resourceUrl }}/images/mall/tswk.png" class="avatar-img not-logged" wx:else mode="aspectFill">
@@ -66,7 +57,7 @@ createComponent({
66
57
  properties: {
67
58
  defaultAvatar: {
68
59
  type: String,
69
- value: ''
60
+ value: getApp().globalData.config.resourceUrl + "/images/mall/tswk.png"
70
61
  },
71
62
  backurl: {
72
63
  type: String,
@@ -100,16 +91,15 @@ createComponent({
100
91
  }
101
92
  };
102
93
  onShow(refreshFunc);
103
- //console.log(resourceUrl);
104
94
  const isLogin = computed(() => userStore.accessToken !== '');
105
95
  return { resourceUrl, baseUrl, userInfo, userStore, refreshFunc, isLogin };
106
96
  },
107
97
  methods: {
108
98
  handleLogin() {
109
99
  console.log("handleLogin");
110
- //检查登录并跳转登录
100
+ // 检查登录并跳转登录
111
101
  this.userStore.loginOnlyAC().then(() => {
112
- //登录成功,加载业务
102
+ // 登录成功,加载业务
113
103
  console.log("静默登录成功");
114
104
  this.refreshFunc();
115
105
  }).catch(() => {
@@ -146,10 +136,8 @@ $bg-card: #ffffff;
146
136
  display: flex;
147
137
  align-items: center;
148
138
  padding: 32rpx 24rpx 32rpx 0;
149
- // background: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
150
139
  border-radius: 20rpx;
151
140
  margin: 16rpx 16rpx 24rpx 0;
152
- // box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04);
153
141
  transition: all 0.3s;
154
142
  background: transparent;
155
143
 
@@ -174,11 +162,8 @@ $bg-card: #ffffff;
174
162
  width: 130rpx;
175
163
  height: 130rpx;
176
164
  border-radius: 50%;
177
- // background-color: $bg-page;
178
165
  display: block;
179
166
  transition: all 0.3s;
180
- // border: 3rpx solid rgba(7, 193, 96, 0.1);
181
- // box-shadow: 0 4rpx 12rpx rgba(7, 193, 96, 0.1);
182
167
 
183
168
  &:active {
184
169
  transform: scale(1.05);
@@ -190,26 +175,6 @@ $bg-card: #ffffff;
190
175
  box-shadow: none;
191
176
  }
192
177
  }
193
-
194
- .avatar-badge {
195
- position: absolute;
196
- right: -2rpx;
197
- bottom: -2rpx;
198
- width: 36rpx;
199
- height: 36rpx;
200
- background: $primary;
201
- border-radius: 50%;
202
- border: 2rpx solid $bg-card;
203
- display: flex;
204
- align-items: center;
205
- justify-content: center;
206
- box-shadow: 0 2rpx 6rpx rgba(7, 193, 96, 0.3);
207
-
208
- .badge-icon {
209
- font-size: 16rpx;
210
- color: #fff;
211
- }
212
- }
213
178
  }
214
179
  }
215
180
 
@@ -254,22 +219,6 @@ $bg-card: #ffffff;
254
219
  }
255
220
  }
256
221
 
257
- .right-arrow {
258
- flex-shrink: 0;
259
- width: 32rpx;
260
- height: 32rpx;
261
- display: flex;
262
- align-items: center;
263
- justify-content: center;
264
-
265
- .arrow-icon {
266
- font-size: 66rpx;
267
- color: $text-3;
268
- font-weight: 300;
269
- line-height: 1;
270
- }
271
- }
272
-
273
222
  // 未登录状态
274
223
  .not-logged-in {
275
224
  .not-logged-wrapper {
@@ -62,7 +62,7 @@ createComponent({
62
62
  type: String,
63
63
  value: ""
64
64
  },
65
- //refreshKey
65
+ // refreshKey
66
66
  refreshKey: {
67
67
  type: Number,
68
68
  value: 0
@@ -70,7 +70,7 @@ createComponent({
70
70
  isLikeStatus.value = response.data === 'true';
71
71
  });
72
72
  }
73
- //监听
73
+ // 监听
74
74
  const { interactId } = toRefs(props)
75
75
  watch(interactId, (newVal) => {
76
76
  queryInteractData(props.organTenant, newVal);
@@ -65,7 +65,7 @@ createComponent({
65
65
  type: String,
66
66
  value: ""
67
67
  },
68
- //refreshKey
68
+ // refreshKey
69
69
  refreshKey: {
70
70
  type: Number,
71
71
  value: 0
@@ -55,7 +55,7 @@ createComponent({
55
55
  type: String,
56
56
  value: ""
57
57
  },
58
- //refreshKey
58
+ // refreshKey
59
59
  refreshKey: {
60
60
  type: Number,
61
61
  value: 0
@@ -23,7 +23,7 @@ createComponent({
23
23
  this.avatar = this.value ? fileApi.imageUrl(this.value, 320, 320, "trans") : this.avatar;
24
24
  }
25
25
  },
26
- // logo图片路径-全路径 编辑回显使用
26
+ // 图片logo路径-全路径 编辑回显使用
27
27
  logoImg: {
28
28
  type: String,
29
29
  value: "",
@@ -53,6 +53,11 @@ createComponent({
53
53
  borderRadius: {
54
54
  type: String,
55
55
  value: "50rpx"
56
+ },
57
+ // 层级
58
+ zIndex: {
59
+ type: Number,
60
+ value: 999999
56
61
  }
57
62
  },
58
63
  setup() {
@@ -8,8 +8,8 @@
8
8
  </view>
9
9
 
10
10
  <!-- 数量输入框 -->
11
- <input class="stepper-input" type="number" value="{{ quantity + '' }}" disabled="{{ disabled }}"
12
- bind:input="handleInput" />
11
+ <input class="stepper-input" type="number" value="{{ displayValue + '' }}" disabled="{{ disabled }}"
12
+ bind:input="handleInput" bind:blur="handleBlur" />
13
13
 
14
14
  <!-- 增加按钮 -->
15
15
  <view class="stepper-btn {{ disabled || incDisabled ? 'disabled' : '' }}"
@@ -44,6 +44,7 @@ createComponent({
44
44
  value: 1,
45
45
  observer() {
46
46
  this.quantity = this.value;
47
+ this.displayValue = this.value;
47
48
  },
48
49
  },
49
50
  // 是否禁用按钮
@@ -60,12 +61,14 @@ createComponent({
60
61
  setup() {
61
62
  // 数量
62
63
  let quantity = ref(1);
64
+ // 输入框显示值(允许为空字符串)
65
+ let displayValue = ref(1 as number | string);
63
66
  // 减少按钮是否禁用
64
67
  let decDisabled = ref(false);
65
68
  // 增加按钮是否禁用
66
69
  let incDisabled = ref(false);
67
70
 
68
- return { quantity, decDisabled, incDisabled }
71
+ return { quantity, displayValue, decDisabled, incDisabled }
69
72
  },
70
73
  lifetimes: {
71
74
  ready() {
@@ -80,6 +83,7 @@ createComponent({
80
83
  // 处理初始值无效的情况
81
84
  if (initValue === null || initValue === undefined) {
82
85
  this.quantity = 1;
86
+ this.displayValue = 1;
83
87
  this.decDisabled = false;
84
88
  this.incDisabled = false;
85
89
  return;
@@ -92,6 +96,7 @@ createComponent({
92
96
  } else {
93
97
  this.quantity = initValue;
94
98
  }
99
+ this.displayValue = this.quantity;
95
100
  // 更新按钮禁用状态
96
101
  this.updateButtonStatus();
97
102
  },
@@ -116,6 +121,7 @@ createComponent({
116
121
  if (this.quantity < this.minNum) {
117
122
  this.quantity = this.minNum;
118
123
  }
124
+ this.displayValue = this.quantity;
119
125
  // 更新按钮禁用状态
120
126
  this.updateButtonStatus();
121
127
  this.triggerEvent("quantity", this.quantity);
@@ -133,6 +139,7 @@ createComponent({
133
139
  if (this.maxNum >= 0 && this.quantity > this.maxNum) {
134
140
  this.quantity = this.maxNum;
135
141
  }
142
+ this.displayValue = this.quantity;
136
143
  // 更新按钮禁用状态
137
144
  this.updateButtonStatus();
138
145
  this.triggerEvent("quantity", this.quantity);
@@ -140,8 +147,14 @@ createComponent({
140
147
 
141
148
  // 输入数量处理
142
149
  handleInput(e: EventBase) {
143
- // 将输入值转为数字,无效输入默认为 1
144
- let value = parseInt(e.detail.value) || 1;
150
+ const rawVal = e.detail.value;
151
+ // 输入框为空,更新显示值但不触发事件
152
+ if (rawVal === "" || rawVal === undefined || rawVal === null) {
153
+ this.displayValue = "";
154
+ return;
155
+ }
156
+ let value = parseInt(rawVal);
157
+ if (isNaN(value)) return;
145
158
  // 确保输入值在 [minNum, maxNum] 范围内
146
159
  if (value < this.minNum) {
147
160
  value = this.minNum;
@@ -149,10 +162,19 @@ createComponent({
149
162
  value = this.maxNum;
150
163
  }
151
164
  this.quantity = value;
165
+ this.displayValue = value;
152
166
  // 更新按钮禁用状态
153
167
  this.updateButtonStatus();
154
168
  this.triggerEvent("quantity", this.quantity);
155
- }
169
+ },
170
+
171
+ // 输入框失焦,如果为空则恢复原值
172
+ handleBlur() {
173
+ if (this.displayValue === "" || this.displayValue === undefined || this.displayValue === null) {
174
+ this.displayValue = this.quantity;
175
+ this.triggerEvent("quantity", this.quantity);
176
+ }
177
+ },
156
178
  }
157
179
  })
158
180
  </script>
@@ -24,7 +24,6 @@ createComponent({
24
24
  },
25
25
  methods: {
26
26
  clickHandler(tab) {
27
- // console.log('tab was clicked', tab)
28
27
  const target = this.tabs.find(item => item.value === tab.detail.value)
29
28
  if (target) {
30
29
  mpx.switchTab({
@@ -33,7 +32,6 @@ createComponent({
33
32
  }
34
33
  },
35
34
  activeTab(value) {
36
- // console.log('activeTab set value:', value)
37
35
  this.selectedLabelDefault = value;
38
36
  }
39
37
  }
@@ -42,9 +40,7 @@ createComponent({
42
40
  <script type="application/json">
43
41
  {
44
42
  "usingComponents": {
45
- "cube-tab-bar": "@mpxjs/mpx-cube-ui/lib/components/tab-bar/index.mpx",
46
- // "cube-tab": "@mpxjs/mpx-cube-ui/lib/components/tab-bar/tab.mpx",
47
- // "cube-icon": "@mpxjs/mpx-cube-ui/lib/components/icon/index.mpx"
43
+ "cube-tab-bar": "@mpxjs/mpx-cube-ui/lib/components/tab-bar/index.mpx"
48
44
  }
49
45
  }
50
46
  </script>
@@ -26,7 +26,7 @@ createComponent({
26
26
  type: String,
27
27
  value: ""
28
28
  },
29
- //refreshKey
29
+ // refreshKey
30
30
  refreshKey: {
31
31
  type: Number,
32
32
  value: 0
@@ -62,8 +62,7 @@ createComponent({
62
62
  type: String,
63
63
  value: "color: #0551ff",
64
64
  },
65
-
66
- //登录后跳转页面
65
+ // 登录后跳转页面
67
66
  backurl: {
68
67
  type: String,
69
68
  value: "/pages/home",
@@ -73,7 +72,7 @@ createComponent({
73
72
  type: String,
74
73
  value: "redirectTo",
75
74
  },
76
- //遮罩层效果
75
+ // 遮罩层效果
77
76
  isShowModel: {
78
77
  type: Boolean,
79
78
  value: false,
@@ -71,8 +71,7 @@ createComponent({
71
71
  type: String,
72
72
  value: "color: #0551ff",
73
73
  },
74
-
75
- //登录后跳转页面
74
+ // 登录后跳转页面
76
75
  backurl: {
77
76
  type: String,
78
77
  value: "/pages/home",
@@ -82,7 +81,7 @@ createComponent({
82
81
  type: String,
83
82
  value: "redirectTo",
84
83
  },
85
- //遮罩层效果
84
+ // 遮罩层效果
86
85
  isShowModel: {
87
86
  type: Boolean,
88
87
  value: false,
@@ -172,7 +172,8 @@ createComponent({
172
172
  </script>
173
173
 
174
174
  <style lang="scss">
175
- $primary: #1677ff; // 支付宝主题色
175
+ // 支付宝主题色
176
+ $primary: #1677ff;
176
177
  $primary-dark: #0958d9;
177
178
  $text-1: #111111;
178
179
  $text-2: #555555;
@@ -7,8 +7,7 @@
7
7
  import { createPage, ref, onLoad } from '@mpxjs/core'
8
8
 
9
9
  createPage({
10
- setup(props) {
11
- //console.log("123", props);
10
+ setup() {
12
11
  let config = getApp().globalData.config;
13
12
  let tenant = ref(config.siteTenant);
14
13
  let siteId = ref(config.siteId);
@@ -6,8 +6,7 @@
6
6
  import { createPage, ref, onLoad } from '@mpxjs/core'
7
7
 
8
8
  createPage({
9
- setup(props) {
10
- //console.log("123", props);
9
+ setup() {
11
10
  let config = getApp().globalData.config;
12
11
  let tenant = ref(config.siteTenant);
13
12
  let siteId = ref(config.siteId);
@@ -6,8 +6,7 @@
6
6
  import { createPage, ref, onLoad } from '@mpxjs/core'
7
7
 
8
8
  createPage({
9
- setup(props) {
10
- //console.log("123", props);
9
+ setup() {
11
10
  let config = getApp().globalData.config;
12
11
  let tenant = ref(config.siteTenant);
13
12
  let siteId = ref(config.siteId);
@@ -15,9 +15,9 @@ createPage({
15
15
  setup() {
16
16
  let isLoginPopup = ref(false);
17
17
  let userStore = useUserStore();
18
- //检查登录并跳转登录
18
+ // 检查登录并跳转登录
19
19
  userStore.loginOnlyAC().then(() => {
20
- //登录成功,加载业务
20
+ // 登录成功,加载业务
21
21
  console.log("静默登录成功");
22
22
  }).catch(() => {
23
23
  isLoginPopup.value = true;
@@ -16,11 +16,11 @@ createPage({
16
16
  setup() {
17
17
  let config = getApp().globalData.config;
18
18
  let userStore = useUserStore();
19
- //强制登录.
19
+ // 强制登录
20
20
  onShow(() => {
21
- //检查登录并跳转登录
21
+ // 检查登录并跳转登录
22
22
  userStore.loginOnlyAC().then(() => {
23
- //登录成功,加载业务
23
+ // 登录成功,加载业务
24
24
  console.log("静默登录成功");
25
25
  }).catch(() => {
26
26
  mpx.navigateTo({
@@ -14,9 +14,9 @@ createPage({
14
14
  setup() {
15
15
  let config = getApp().globalData.config;
16
16
  let userStore = useUserStore();
17
- //强制登录.
17
+ // 强制登录
18
18
  onShow(() => {
19
- //检查登录并跳转登录
19
+ // 检查登录并跳转登录
20
20
  userStore.loginAC("/pages/home2", false).then((res) => {
21
21
  console.log(res);
22
22
  });
package/src/store/user.ts CHANGED
@@ -154,7 +154,6 @@ export const useUserStore = defineStore("user", {
154
154
  },
155
155
  // 登录处理
156
156
  loginProcess(resp: ResponseData<LoginRes>): LoginRes {
157
- //console.log("miniappLogin", resp);
158
157
  if (resp.statusCode === 200 && resp.data.status === true) {
159
158
  console.log("login success");
160
159
  this.loginSuccess(resp.data.token);
@@ -164,7 +164,6 @@ export const validateRequired = (
164
164
  value: string | number,
165
165
  message: string
166
166
  ): boolean => {
167
- console.log(value, message);
168
167
  const valueStr = typeof value === "number" ? String(value) : value;
169
168
  if (!valueStr || valueStr.trim() === "") {
170
169
  // 显示错误提示
@@ -18,7 +18,6 @@ mpx.xfetch.interceptors.request.use(function (config) {
18
18
  const appconfig = getApp().globalData.config;
19
19
  config.url = appconfig.baseUrl + config.url;
20
20
  }
21
- //console.log("request:", config);
22
21
  // Grpc Gateway 清理默认值,Enum,时间等不能空;
23
22
  grpc.clearEmpty(config.params);
24
23
  grpc.clearEmpty(config.data);
@@ -52,7 +51,6 @@ mpx.xfetch.interceptors.request.use(function (config) {
52
51
  } else {
53
52
  delete config.header["Grpc-Metadata-Tenant"];
54
53
  }
55
- //console.log("header:", config.header);
56
54
  } else if (!db.getRefreshToken()) {
57
55
  console.log("not token request. ");
58
56
  return config;
@@ -96,7 +94,6 @@ mpx.xfetch.interceptors.request.use(function (config) {
96
94
  });
97
95
 
98
96
  mpx.xfetch.interceptors.response.use(function (res) {
99
- // console.log(“response:”,res);
100
97
  if (res.statusCode === 200) {
101
98
  return res;
102
99
  } else if (res.statusCode === 401) {