@smart100/spu-web-plugin 0.0.30 → 0.0.32

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.
@@ -708,7 +708,7 @@ function _toPropertyKey$1(arg) {
708
708
  return typeof key === "symbol" ? key : String(key);
709
709
  }
710
710
 
711
- var version = "0.0.30";
711
+ var version = "0.0.32";
712
712
 
713
713
  /** Detect free variable `global` from Node.js. */
714
714
  var freeGlobal$2 = typeof global == 'object' && global && global.Object === Object && global;
@@ -12106,6 +12106,8 @@ var WxworksuiteBaseOpendata = /*#__PURE__*/function (_LitElement) {
12106
12106
  _this.type = ''; // userName | departmentName
12107
12107
  _this.mode = 'close'; // open | close
12108
12108
  _this._isCanUseWxworkSuite = true;
12109
+ _this._isRealOpenid = true;
12110
+ _this._topWWOpenData = null;
12109
12111
  return _this;
12110
12112
  }
12111
12113
  _createClass(WxworksuiteBaseOpendata, [{
@@ -12118,32 +12120,12 @@ var WxworksuiteBaseOpendata = /*#__PURE__*/function (_LitElement) {
12118
12120
  key: "connectedCallback",
12119
12121
  value: function () {
12120
12122
  var _connectedCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
12121
- var _this2 = this;
12122
12123
  return _regeneratorRuntime().wrap(function _callee$(_context) {
12123
12124
  while (1) switch (_context.prev = _context.next) {
12124
12125
  case 0:
12125
12126
  _get(_getPrototypeOf(WxworksuiteBaseOpendata.prototype), "connectedCallback", this).call(this);
12126
12127
  // console.log('connectedCallback')
12127
- jssdk.init().then(function (_ref) {
12128
- var topWWOpenData = _ref.topWWOpenData;
12129
- _this2._isCanUseWxworkSuite = true;
12130
- if (_this2.wwopendataRef) {
12131
- if (topWWOpenData) {
12132
- topWWOpenData.bind(_this2.wwopendataRef);
12133
- // topWWOpenData.on('update', (event: any) => {
12134
- // const openid = event.detail.element.getAttribute('openid')
12135
- // console.log('渲染数据发生变更', event, openid)
12136
- // })
12137
- topWWOpenData.on('error', function (event) {
12138
- // console.error('获取数据失败', event)
12139
- _this2._isCanUseWxworkSuite = false;
12140
- });
12141
- }
12142
- }
12143
- })["catch"](function (err) {
12144
- // console.error('jssdk.init() fail', err)
12145
- _this2._isCanUseWxworkSuite = false;
12146
- });
12128
+ this._deal();
12147
12129
  case 2:
12148
12130
  case "end":
12149
12131
  return _context.stop();
@@ -12154,7 +12136,17 @@ var WxworksuiteBaseOpendata = /*#__PURE__*/function (_LitElement) {
12154
12136
  return _connectedCallback.apply(this, arguments);
12155
12137
  }
12156
12138
  return connectedCallback;
12157
- }() // private test (e: Event) {
12139
+ }()
12140
+ }, {
12141
+ key: "updated",
12142
+ value: function updated(changedProperties) {
12143
+ // 页面在浏览器,在 iOS,Mac,Android 上面的企业微信都表现正常,但是在 windows 企业微信下,会偶发不能渲染通讯录控件内容
12144
+ // 解答:由于 企业微信的 windows 客户端浏览器内核不支持 customElements,每次更新了 open-data 元素后,需要用 bind 或者 bindAll 接口对目标元素进行一次更新,这样才能保证 open-data 元素实时渲染正确的数据。遇到上面的情况,请检查一下页面代码,看看有没有可能出现时序问题:先执行了 bind,然后才渲染出对应的 open-data 元素
12145
+ if (changedProperties.has('openid') || changedProperties.has('type')) {
12146
+ this._deal();
12147
+ }
12148
+ }
12149
+ // private test (e: Event) {
12158
12150
  // // console.log(this.shadowRoot)
12159
12151
  // // console.log(this.renderRoot)
12160
12152
  // // console.log(this.shadowRoot?.querySelector('#aaaa'))
@@ -12164,6 +12156,45 @@ var WxworksuiteBaseOpendata = /*#__PURE__*/function (_LitElement) {
12164
12156
  // console.log(value)
12165
12157
  // this._isCanUseWxworkSuite = !this._isCanUseWxworkSuite
12166
12158
  // }
12159
+ }, {
12160
+ key: "_deal",
12161
+ value: function _deal() {
12162
+ var _this2 = this;
12163
+ if (this.type === 'userName') {
12164
+ this._isRealOpenid = this.openid.length >= 32 && !/[\u4e00-\u9fa5]/g.test(this.openid);
12165
+ } else if (this.type === 'departmentName') {
12166
+ this._isRealOpenid = Number.isInteger(Number(this.openid));
12167
+ }
12168
+ jssdk.init().then(function (_ref) {
12169
+ var topWWOpenData = _ref.topWWOpenData;
12170
+ _this2._isCanUseWxworkSuite = true;
12171
+ setTimeout(function () {
12172
+ if (_this2.wwopendataRef) {
12173
+ if (topWWOpenData) {
12174
+ _this2._topWWOpenData = topWWOpenData;
12175
+ topWWOpenData.bind(_this2.wwopendataRef);
12176
+ // topWWOpenData.on('update', (event: any) => {
12177
+ // const openid = event.detail.element.getAttribute('openid')
12178
+ // console.log('渲染数据发生变更', event, openid)
12179
+ // if (this.type === 'departmentName') {
12180
+ // console.log('渲染数据发生变更', event)
12181
+ // console.log('渲染数据发生变更', openid)
12182
+ // }
12183
+ // })
12184
+ topWWOpenData.on('error', function (event) {
12185
+ // console.error('获取数据失败', event)
12186
+ _this2._isCanUseWxworkSuite = false;
12187
+ _this2._topWWOpenData = null;
12188
+ });
12189
+ }
12190
+ }
12191
+ }, 0);
12192
+ })["catch"](function (err) {
12193
+ // console.error('jssdk.init() fail', err)
12194
+ _this2._isCanUseWxworkSuite = false;
12195
+ _this2._topWWOpenData = null;
12196
+ });
12197
+ }
12167
12198
  }, {
12168
12199
  key: "getValue",
12169
12200
  value: function getValue() {
@@ -12199,7 +12230,7 @@ var WxworksuiteBaseOpendata = /*#__PURE__*/function (_LitElement) {
12199
12230
  // <button @click="${this.test}">test</button>
12200
12231
  // ${this._isCanUseWxworkSuite ? html`<ww-open-data type="${this.type}" openid="${this.openid}" mode="${this.mode}" />` : this.openid}
12201
12232
  // ${ this._isCanUseWxworkSuite ? html`true` : 'false' }
12202
- return x(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteral(["\n ", "\n "])), this._isCanUseWxworkSuite ? x(_templateObject2$5 || (_templateObject2$5 = _taggedTemplateLiteral(["<ww-open-data type=\"", "\" openid=\"", "\" mode=\"", "\" />"])), this.type, this.openid, this.mode) : this.openid);
12233
+ return x(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteral(["\n ", "\n "])), this._isCanUseWxworkSuite && this._isRealOpenid ? x(_templateObject2$5 || (_templateObject2$5 = _taggedTemplateLiteral(["<ww-open-data type=\"", "\" openid=\"", "\" mode=\"", "\" />"])), this.type, this.openid, this.mode) : this.openid);
12203
12234
  }
12204
12235
  }], [{
12205
12236
  key: "register",
@@ -12213,7 +12244,7 @@ var WxworksuiteBaseOpendata = /*#__PURE__*/function (_LitElement) {
12213
12244
  }(s$1);
12214
12245
  _class$7 = WxworksuiteBaseOpendata;
12215
12246
  _class$7.componentName = 'wxworksuite-base-opendata';
12216
- _class$7.styles = i$4(_templateObject3$3 || (_templateObject3$3 = _taggedTemplateLiteral(["\n :host {}\n "])));
12247
+ _class$7.styles = i$4(_templateObject3$3 || (_templateObject3$3 = _taggedTemplateLiteral([""])));
12217
12248
  __decorate([n$1({
12218
12249
  type: String
12219
12250
  })], WxworksuiteBaseOpendata.prototype, "openid", void 0);
@@ -12224,6 +12255,8 @@ __decorate([n$1({
12224
12255
  type: String
12225
12256
  })], WxworksuiteBaseOpendata.prototype, "mode", void 0);
12226
12257
  __decorate([r$1()], WxworksuiteBaseOpendata.prototype, "_isCanUseWxworkSuite", void 0);
12258
+ __decorate([r$1()], WxworksuiteBaseOpendata.prototype, "_isRealOpenid", void 0);
12259
+ __decorate([r$1()], WxworksuiteBaseOpendata.prototype, "_topWWOpenData", void 0);
12227
12260
 
12228
12261
  /**
12229
12262
  * @license
@@ -12555,9 +12588,25 @@ var WxworksuiteTree = /*#__PURE__*/function (_LitElement) {
12555
12588
  } else {
12556
12589
  _this._searchlist = _this._list.filter(function (item) {
12557
12590
  if (_this.wwopendatatype !== 'expression') {
12558
- return searchOptions.some(function (item2) {
12559
- return item2.id.toString() === item.name.toString();
12560
- });
12591
+ if (_this.wwopendatatype === 'userName') {
12592
+ var isRealOpenid = item.name.length >= 32 && !/[\u4e00-\u9fa5]/g.test(item.name);
12593
+ if (isRealOpenid) {
12594
+ return searchOptions.some(function (item2) {
12595
+ return item2.id.toString() === item.name.toString();
12596
+ });
12597
+ } else {
12598
+ return item.name.indexOf(_this._searchvalue) !== -1;
12599
+ }
12600
+ } else if (_this.wwopendatatype === 'departmentName') {
12601
+ var _isRealOpenid = Number.isInteger(Number(item.name));
12602
+ if (_isRealOpenid) {
12603
+ return searchOptions.some(function (item2) {
12604
+ return item2.id.toString() === item.name.toString();
12605
+ });
12606
+ } else {
12607
+ return item.name.indexOf(_this._searchvalue) !== -1;
12608
+ }
12609
+ }
12561
12610
  } else {
12562
12611
  // return searchOptions.some((item2: any) => item.name.toString().indexOf(item2.id.toString()) !== -1)
12563
12612
  var arr = getExpressionArr(item.name);
@@ -13253,6 +13302,7 @@ var WxworksuiteOrganizationpickMobile = /*#__PURE__*/function (_LitElement) {
13253
13302
  _this.displaytype = 'mobile';
13254
13303
  _this.ismulselect = false;
13255
13304
  _this.issearch = true;
13305
+ _this.userule = true;
13256
13306
  _this.searchplaceholder = '请输入关键字搜索';
13257
13307
  // normal 父子有关联 共同取值 半选不取
13258
13308
  // individual 父子无关联 各自独立取值
@@ -13266,14 +13316,32 @@ var WxworksuiteOrganizationpickMobile = /*#__PURE__*/function (_LitElement) {
13266
13316
  _this.singleselectmode = 'normal';
13267
13317
  _this._expandicon = 'organization';
13268
13318
  _this._list = [];
13269
- normalAxios$1.post('/api/teapi/dy-biz/100000000000000000/110000000000000000', {
13270
- pl_orgstruct: {
13271
- status: '1'
13272
- }
13319
+ // axios.post('/api/teapi/dy-biz/100000000000000000/110000000000000000', {
13320
+ // pl_orgstruct: {
13321
+ // status: '1'
13322
+ // }
13323
+ // }).then((res: any) => {
13324
+ // // console.log(res)
13325
+ // const list = res?.data?.pl_orgstruct || []
13326
+ // list.forEach((item: any) => {
13327
+ // item.name = item.orgname
13328
+ // // item.name = '1'
13329
+ // item.id = item.orgstructid
13330
+ // item.pid = item.parentorgstructid
13331
+ // })
13332
+ // this._list = list
13333
+ // })
13334
+ normalAxios$1.post('/api/system/v1.0/org/page', {
13335
+ showchild: true,
13336
+ orgstructtypeid: 1,
13337
+ useRule: _this.userule,
13338
+ pageindex: 1,
13339
+ pagesize: 99999,
13340
+ getAllStatus: false // 是否获取全部数据(即包含禁用)
13273
13341
  }).then(function (res) {
13274
13342
  var _res$data;
13275
13343
  // console.log(res)
13276
- var list = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.pl_orgstruct) || [];
13344
+ var list = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [];
13277
13345
  list.forEach(function (item) {
13278
13346
  item.name = item.orgname;
13279
13347
  // item.name = '1'
@@ -13376,6 +13444,9 @@ __decorate([n$1({
13376
13444
  __decorate([n$1({
13377
13445
  type: Boolean
13378
13446
  })], WxworksuiteOrganizationpickMobile.prototype, "issearch", void 0);
13447
+ __decorate([n$1({
13448
+ type: Boolean
13449
+ })], WxworksuiteOrganizationpickMobile.prototype, "userule", void 0);
13379
13450
  __decorate([n$1({
13380
13451
  type: String
13381
13452
  })], WxworksuiteOrganizationpickMobile.prototype, "searchplaceholder", void 0);
@@ -13428,6 +13499,7 @@ var WxworksuiteMemberpickMobile = /*#__PURE__*/function (_LitElement) {
13428
13499
  _this.displaytype = 'mobile';
13429
13500
  _this.ismulselect = false;
13430
13501
  _this.issearch = true;
13502
+ _this.userule = true;
13431
13503
  _this.searchplaceholder = '请输入关键字搜索';
13432
13504
  // normal 父子有关联 共同取值 半选不取
13433
13505
  // individual 父子无关联 各自独立取值
@@ -13440,22 +13512,47 @@ var WxworksuiteMemberpickMobile = /*#__PURE__*/function (_LitElement) {
13440
13512
  // disable 不能选非末级节点 只能选末级节点 暂不实现
13441
13513
  _this.singleselectmode = 'normal';
13442
13514
  _this._list = [];
13443
- normalAxios$1.post('/api/teapi/dy-biz/1032470355689738336/1273067686762516579', {
13444
- member: {
13445
- searchkey: '',
13446
- orglimit: '',
13447
- orgstructid: '',
13448
- email: '',
13449
- includechild: '1'
13450
- }
13515
+ // axios.post('/api/teapi/dy-biz/1032470355689738336/1273067686762516579', {
13516
+ // member: {
13517
+ // searchkey: '',
13518
+ // orglimit: '',
13519
+ // orgstructid: '',
13520
+ // email: '',
13521
+ // includechild: '1'
13522
+ // }
13523
+ // }).then((res: any) => {
13524
+ // // console.log(res)
13525
+ // const list = res?.data?.member || []
13526
+ // list.forEach((item: any, index: number) => {
13527
+ // item.name = `__$$wwopendata(${item.userinfoname}, userName)(${item.positionname})`
13528
+ // // item.name = `__$$wwopendata(${item.userinfoname}, userName)(${item.positionname})__$$wwopendata(哈哈+${index}, departmentName)`
13529
+ // item.id = item.memberid
13530
+ // item.pid = ''
13531
+ // item.iswwopendata = true
13532
+ // item.wwopendatatype = 'expression'
13533
+ // })
13534
+ // this._list = list
13535
+ // })
13536
+ normalAxios$1.post('/api/system/v1.0/member/getMemberList', {
13537
+ name: '',
13538
+ phoneNumber: '',
13539
+ saleAreaCodePath: '',
13540
+ positionName: '',
13541
+ pageindex: 1,
13542
+ pagesize: 99999,
13543
+ // useRule: false, // 使用数据权限
13544
+ // useRule: this.userule, // 使用数据权限
13545
+ appcode: 'sales',
13546
+ belongDistributorId: ''
13451
13547
  }).then(function (res) {
13452
13548
  var _res$data;
13453
13549
  // console.log(res)
13454
- var list = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.member) || [];
13550
+ // debugger
13551
+ var list = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [];
13455
13552
  list.forEach(function (item, index) {
13456
- item.name = "__$$wwopendata(".concat(item.userinfoname, ", userName)(").concat(item.positionname, ")");
13457
- // item.name = `__$$wwopendata(${item.userinfoname}, userName)(${item.positionname})__$$wwopendata(哈哈+${index}, departmentName)`
13458
- item.id = item.memberid;
13553
+ item.name = "__$$wwopendata(".concat(item.userName, ", userName)(").concat(item.positionName, ")");
13554
+ // item.name = `__$$wwopendata(${item.userName}, userName)(${item.positionName})__$$wwopendata(哈哈+${index}, departmentName)`
13555
+ item.id = item.memberId;
13459
13556
  item.pid = '';
13460
13557
  item.iswwopendata = true;
13461
13558
  item.wwopendatatype = 'expression';
@@ -13556,6 +13653,9 @@ __decorate([n$1({
13556
13653
  __decorate([n$1({
13557
13654
  type: Boolean
13558
13655
  })], WxworksuiteMemberpickMobile.prototype, "issearch", void 0);
13656
+ __decorate([n$1({
13657
+ type: Boolean
13658
+ })], WxworksuiteMemberpickMobile.prototype, "userule", void 0);
13559
13659
  __decorate([n$1({
13560
13660
  type: String
13561
13661
  })], WxworksuiteMemberpickMobile.prototype, "searchplaceholder", void 0);
@@ -59334,7 +59434,7 @@ var getIndextagSync = function getIndextagSync(params) {
59334
59434
  var initApaasSpuTrack = function initApaasSpuTrack() {
59335
59435
  setTimeout(function () {
59336
59436
  var _window, _window2;
59337
- if (ApaasSpuTrack && !window.apaasSpuTrack && !((_window = window) !== null && _window !== void 0 && (_window = _window.aPaaS) !== null && _window !== void 0 && _window.getWebInitParams) && !((_window2 = window) !== null && _window2 !== void 0 && (_window2 = _window2.Module) !== null && _window2 !== void 0 && _window2.getIndextagSync)) {
59437
+ if (ApaasSpuTrack && !window.apaasSpuTrack && !((_window = window) !== null && _window !== void 0 && (_window = _window.aPaaS) !== null && _window !== void 0 && _window.getWebInitParams) && !((_window2 = window) !== null && _window2 !== void 0 && (_window2 = _window2.Module) !== null && _window2 !== void 0 && _window2.getIndextagSync) && login.checkLogin() && getUser()) {
59338
59438
  window.aPaaS = {
59339
59439
  getWebInitParams: getWebInitParams
59340
59440
  };
@@ -59418,10 +59518,10 @@ var initApaasSpuTrack = function initApaasSpuTrack() {
59418
59518
  apaasSpuTrack.start();
59419
59519
  });
59420
59520
  }
59421
- }, 2500);
59521
+ }, 3000);
59422
59522
  };
59423
59523
  var apaasSpuTrackSendLog = function apaasSpuTrackSendLog(data) {
59424
- var end = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
59524
+ var isnotretry = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
59425
59525
  if (window.apaasSpuTrack) {
59426
59526
  var logtime = Date.now().toString();
59427
59527
  var baselog = cloneDeep$1(_objectSpread2$1(_objectSpread2$1({}, window.apaasSpuTrack.baseLog), {}, {
@@ -59448,7 +59548,7 @@ var apaasSpuTrackSendLog = function apaasSpuTrackSendLog(data) {
59448
59548
  // debugger
59449
59549
  window.apaasSpuTrack.addLogToQueue(mergedata, true);
59450
59550
  } else {
59451
- if (!end) {
59551
+ if (!isnotretry) {
59452
59552
  console.warn('window.apaasSpuTrack 不存在,导出日志延迟3秒后再次发送。');
59453
59553
  setTimeout(function () {
59454
59554
  apaasSpuTrackSendLog(data, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart100/spu-web-plugin",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "npm run build:types && rollup -c -w",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@amap/amap-jsapi-loader": "^1.0.1",
41
- "@smart100/wxworksuite-plugin": "^0.0.9",
41
+ "@smart100/wxworksuite-plugin": "^0.0.11",
42
42
  "axios": "^1.6.0",
43
43
  "co": "^4.6.0",
44
44
  "dayjs": "^1.11.10",
@@ -1,5 +1,6 @@
1
1
  import { globalOptions, getUser, Module } from './index'
2
2
  import { cloneDeep, merge } from 'lodash-es'
3
+ import login from './login'
3
4
 
4
5
  // @ts-ignore
5
6
  import ApaasSpuTrack from './package/apaas-track/apaas-spu/index.umd.js'
@@ -55,7 +56,7 @@ const getIndextagSync = (params: any) => {
55
56
  // 兼容开启SPU日志
56
57
  const initApaasSpuTrack = () => {
57
58
  setTimeout(() => {
58
- if (ApaasSpuTrack && !window.apaasSpuTrack && !window?.aPaaS?.getWebInitParams && !window?.Module?.getIndextagSync) {
59
+ if (ApaasSpuTrack && !window.apaasSpuTrack && !window?.aPaaS?.getWebInitParams && !window?.Module?.getIndextagSync && login.checkLogin() && getUser()) {
59
60
  window.aPaaS = {
60
61
  getWebInitParams
61
62
  }
@@ -147,10 +148,10 @@ const initApaasSpuTrack = () => {
147
148
  apaasSpuTrack.start()
148
149
  })
149
150
  }
150
- }, 2500)
151
+ }, 3000)
151
152
  }
152
153
 
153
- const apaasSpuTrackSendLog = (data: any, end: boolean = false) => {
154
+ const apaasSpuTrackSendLog = (data: any, isnotretry: boolean = false) => {
154
155
  if (window.apaasSpuTrack) {
155
156
  const logtime = Date.now().toString()
156
157
  const baselog = cloneDeep({
@@ -178,7 +179,7 @@ const apaasSpuTrackSendLog = (data: any, end: boolean = false) => {
178
179
  // debugger
179
180
  window.apaasSpuTrack.addLogToQueue(mergedata, true)
180
181
  } else {
181
- if (!end) {
182
+ if (!isnotretry) {
182
183
  console.warn('window.apaasSpuTrack 不存在,导出日志延迟3秒后再次发送。')
183
184
  setTimeout(() => {
184
185
  apaasSpuTrackSendLog(data, true)