jufubao-third 1.0.19-beta2 → 1.0.19-beta3

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.
@@ -898,14 +898,78 @@ handleCustom({ action, data }) {
898
898
 
899
899
  #### 1.3 XdFont 字体样式
900
900
 
901
- **功能**:配置文字样式,包括颜色、字号、行高、粗细、对齐等。
901
+ **功能**:配置文字样式,包括颜色、字号、行高、粗细、对齐等。返回对象格式 `{color, fontSize, fontWeight, ...}`。
902
902
 
903
903
  **用途**:用于设置字体样式,如字号、颜色、粗细等,支持默认、自定义等选项。
904
904
 
905
- **完整例子**(在 Attr.js 中配置):
905
+ **返回值格式**:
906
+ | 属性 | 类型 | 说明 |
907
+ |------|------|------|
908
+ | `color` | String | 文字颜色,如 `'#333'` |
909
+ | `fontSize` | String | 字号,如 `'28rpx'` |
910
+ | `fontWeight` | String/Number | 字重,如 `'normal'`、`'bold'` |
911
+ | `lineHeight` | String | 行高,如 `'40rpx'` |
912
+ | `textAlign` | String | 对齐方式 |
913
+
914
+ **完整例子 — 配合 D/C 默认/自定义组**(在 Attr.js 中配置):
906
915
 
907
916
  ```javascript
908
- // 来源:示例代码(可参考 JfbMallHomeProductList/cusAttr/style.js 中的 xd-text-and-bgc 配置)
917
+ // 来源:/JfbThirdCopyUrl/cusAttr/content.js:145-190
918
+ // 完整 D/C 组包装模式
919
+ // D/C 单选
920
+ {
921
+ label: '文字',
922
+ ele: 'xd-radio',
923
+ groupKey: 'content',
924
+ valueKey: 'btnFontStatus',
925
+ value: statusDataVal({data, key: 'btnFontStatus', fields: ['btnFont'], gValue}),
926
+ labelInline: true,
927
+ list: [
928
+ {label: '默认', value: 'D'},
929
+ {label: '自定义', value: 'C'},
930
+ ]
931
+ },
932
+ {ele: 'group_start'},
933
+ {
934
+ label: '',
935
+ ele: 'xd-font',
936
+ groupKey: 'content',
937
+ valueKey: 'btnFont',
938
+ // 注意:xd-font 返回对象,dValue 设为 null
939
+ value: dataVal({data, key: 'btnFont', dValue: null, gValue}),
940
+ hidden: !statusShow({data, key: 'btnFontStatus', fields: ['btnFont'], gValue}),
941
+ setting: {
942
+ color: true, // 文字颜色
943
+ fontSize: true, // 字号(启用后必须配置 handleCustom)
944
+ weight: true, // 字重
945
+ lineHeight: false,
946
+ align: false,
947
+ icon: false,
948
+ default: {
949
+ color: '#333',
950
+ fontSize: '28',
951
+ weight: 'normal',
952
+ },
953
+ },
954
+ // 启用 fontSize 时必须配置,用于获取字号选项列表
955
+ handleCustom({action, data}) {
956
+ XdBus.getParentApi('getOptionsSettingList')({setting_id: 'edtix_style_font_size'})
957
+ .then(res => {
958
+ data.cb(res.list)
959
+ })
960
+ .catch(error => {
961
+ console.error(error);
962
+ data.cb([])
963
+ });
964
+ },
965
+ },
966
+ {ele: 'group_end'},
967
+ ```
968
+
969
+ **简化例子 — 无 D/C 组**(在 Attr.js 中配置):
970
+
971
+ ```javascript
972
+ // 来源:/JfbMallHomeProductList/cusAttr/style.js
909
973
  {
910
974
  label: '标题字体样式',
911
975
  ele: 'xd-font',
@@ -945,6 +1009,39 @@ handleCustom({ action, data }) {
945
1009
  }
946
1010
  ```
947
1011
 
1012
+ **Vue 组件取值与样式应用**:
1013
+
1014
+ ```javascript
1015
+ // init 中获取 xd-font 返回值(对象格式)
1016
+ this.btnFont = gCPVal(container, 'btnFont', [{color: '#333', fontSize: '28rpx', fontWeight: 'normal'}], {
1017
+ sKey: 'btnFontStatus', fields: ['btnFont']
1018
+ });
1019
+
1020
+ // 应用到行内样式
1021
+ if(this.btnFont) {
1022
+ if(this.btnFont.color) style.color = this.btnFont.color;
1023
+ if(this.btnFont.fontSize) style.fontSize = this.btnFont.fontSize;
1024
+ if(this.btnFont.fontWeight) style.fontWeight = this.btnFont.fontWeight;
1025
+ }
1026
+ ```
1027
+
1028
+ **setting 配置说明**:
1029
+
1030
+ | 属性 | 类型 | 说明 |
1031
+ |------|------|------|
1032
+ | color | Boolean | 是否启用颜色选择 |
1033
+ | fontSize | Boolean | 是否启用字号选择(启用必须配置 handleCustom) |
1034
+ | weight | Boolean | 是否启用字重选择 |
1035
+ | lineHeight | Boolean | 是否启用行高设置 |
1036
+ | align | Boolean | 是否启用对齐方式 |
1037
+ | icon | Boolean | 是否启用图标选择 |
1038
+ | decoration | Boolean | 是否启用装饰线 |
1039
+ | isEmpty | Boolean | 是否清空所有默认值 |
1040
+ | default | Object | 默认值对象,属性取决于启用的功能 |
1041
+ | default.color | String | 默认颜色 |
1042
+ | default.fontSize | String/Number | 默认字号(数字格式,不含单位) |
1043
+ | default.weight | String/Number | 默认字重 |
1044
+
948
1045
  #### 1.4 XdBorder 边框设置
949
1046
 
950
1047
  **功能**:配置元素边框样式、宽度和颜色。
@@ -1409,6 +1506,39 @@ handleCustom({ action, data }) {
1409
1506
  // statusShow - 判断是否显示关联字段
1410
1507
  ```
1411
1508
 
1509
+ **技巧 — 背景图建议尺寸动态计算**:
1510
+
1511
+ `tipsformet` 中的建议宽度不应写死,可通过 `getAttrData` 动态计算:
1512
+
1513
+ ```javascript
1514
+ // Attr.js 中配置(静态 part)
1515
+ tipsformet: '上传文件格式:@imageType@,不超过@size@MB., 建议宽度为:<span style="color:red">'+ this.x_outerW +'</span>像素',
1516
+ ```
1517
+
1518
+ ```javascript
1519
+ // Vue init() 中动态计算 x_outerW
1520
+ init(container) {
1521
+ getAttrData({
1522
+ sel: this.getInitData,
1523
+ objData: {
1524
+ // 根据外边距 + 组件高度计算背景图建议宽度
1525
+ _outerW: (container) => {
1526
+ const marginData = this.getPMarginRLTB(this.getButtonMarginData(container));
1527
+ const targetH = gCPVal(container, 'btnHeight', [48]);
1528
+ this.x_outerW = marginData ? `${750 * targetH / 48}` : '750';
1529
+ }
1530
+ }
1531
+ });
1532
+ }
1533
+ ```
1534
+
1535
+ **要点**:
1536
+ - `this.x_outerW` 作为动态属性挂载,在 `tipsformet` 字符串中直接引用
1537
+ - 需要在 `init()` 中先计算再渲染,确保 `tipsformet` 获取到的是计算后的值
1538
+ - 计算公式可根据组件实际尺寸比例调整(如 `宽度 = 基准宽度 × 高度 / 基准高度`)
1539
+
1540
+ ---
1541
+
1412
1542
  ### 2、Selector 选择器组件
1413
1543
 
1414
1544
  #### 2.1 XdIconSelect 图标选择器
@@ -1187,6 +1187,25 @@ module.exports = {
1187
1187
  2. **语义化命名**:类名应清晰表达区域功能,避免无意义命名
1188
1188
  3. **避免过深层级**:嵌套建议不超过 5 层,过深时应考虑拆分组件
1189
1189
  4. **使用 Less 变量**:颜色、间距等优先使用项目统一变量
1190
+ 5. **避免 CSS `background` 简写覆盖**:使用 `background` 简写属性会重置所有子属性(background-size、background-repeat、background-position 等),导致背景图配置失效。应拆分为独立属性:
1191
+
1192
+ ```less
1193
+ // ❌ 错误:简写会重置 background-size 等
1194
+ .btn {
1195
+ background: url('xxx.png') #fff;
1196
+ background-size: cover; // 被上一行重置,无效!
1197
+ }
1198
+
1199
+ // ✅ 正确:使用独立属性,互不影响
1200
+ .btn {
1201
+ background-color: #fff;
1202
+ background-image: url('xxx.png');
1203
+ background-size: cover;
1204
+ background-repeat: no-repeat;
1205
+ }
1206
+ ```
1207
+
1208
+ **典型场景**:组件中背景色和背景图分别由 `content.btnBgColor` 和 `content.btnBgImage` 控制,动态 computed style 中应分别设置 `background-color` 和 `background-image`,而非合并为 `background`。
1190
1209
 
1191
1210
  ---
1192
1211
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jufubao-third",
3
- "version": "1.0.19-beta2",
3
+ "version": "1.0.19-beta3",
4
4
  "private": false,
5
5
  "description": "聚福宝业务组件第三方购物平台包",
6
6
  "main": "index.js",
@@ -115,7 +115,7 @@
115
115
  */
116
116
  init(container) {
117
117
  //基础
118
- this.serverApi = '/thirdmall-apiuri/v1/food/haiwei365/brand/20045'///gCPVal(container, 'serverApi', '');
118
+ this.serverApi = gCPVal(container, 'serverApi', '');
119
119
  this.btnText = gCPVal(container, 'btnText', '复制链接');
120
120
  //样式设置
121
121
  this.height = gCPVal(container, 'height', 48, {sKey: 'heightStatus', fields: ['height']});
@@ -166,7 +166,7 @@
166
166
  }
167
167
  // #ifdef H5
168
168
  this.$copyText(this.copyUrl).then(() => {
169
- this.$xdAlert({content: '复制成功'});
169
+ this.$xdAlert({content: '内容已复制'});
170
170
  }).catch(() => {
171
171
  this.$xdAlert({content: '复制失败,请手动复制'});
172
172
  });
@@ -174,8 +174,9 @@
174
174
  // #ifndef H5
175
175
  uni.setClipboardData({
176
176
  data: this.copyUrl,
177
+ showToast:false,
177
178
  success: () => {
178
- this.$xdAlert({content: '复制成功'});
179
+ //this.$xdAlert({content: '内容已复制'});
179
180
  },
180
181
  fail: () => {
181
182
  this.$xdAlert({content: '复制失败,请手动复制'});