wl-design-mobile 0.1.8 → 0.2.0

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.
@@ -15,7 +15,8 @@
15
15
  </div>
16
16
  <div :style="{ height: listHeight }" class="custom-list">
17
17
  <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
18
- <van-list v-model="loading" :finished="finished" :finished-text="finishedTxt" :offset="200" @load="onLoad">
18
+ <van-list v-model="loading" :finished="finished" :finished-text="finishedTxt" :offset="200" @load="onLoad"
19
+ :error.sync="error" :error-text="errorText" :immediate-check="false">
19
20
  <div v-for="(item, index) in list" :key="index" class="list-item">
20
21
  <div class="card-item">
21
22
  <slot name="head" v-bind:item="item"></slot>
@@ -51,7 +52,7 @@ export default {
51
52
  data() {
52
53
  return {
53
54
  loading: false,
54
- finished: true,
55
+ finished: false,
55
56
  finishedTxt: "",
56
57
  pageNum: 1, // 当前页数
57
58
  pageSize: 10, // 每页数据条数
@@ -60,6 +61,8 @@ export default {
60
61
  offset: 0,
61
62
  limit: 10,
62
63
  list: [],
64
+ error:false,
65
+ errorText:''
63
66
  };
64
67
  },
65
68
  mounted() {
@@ -87,23 +90,30 @@ export default {
87
90
  this.list = [];
88
91
  this.refreshing = false;
89
92
  }
93
+ this.loading = true
90
94
  if (this.testMode === true) {
91
- let arr = [
92
- {title: "盐城市亭湖区大树酒业商行", time: "2024-01-01", person:"01", dpt: "储配部", note: "测试"},
93
- {title: "盐城市亭湖区大树酒业商行", time: "2024-01-02", person:"02", dpt: "储配部", note: "测试"},
94
- {title: "盐城市亭湖区大树酒业商行", time: "2024-01-01", person:"01", dpt: "储配部", note: "测试"},
95
- {title: "盐城市亭湖区大树酒业商行", time: "2024-01-02", person:"02", dpt: "储配部", note: "测试"},
96
- {title: "盐城市亭湖区大树酒业商行", time: "2024-01-01", person:"01", dpt: "储配部", note: "测试"},
97
- {title: "盐城市亭湖区大树酒业商行", time: "2024-01-02", person:"02", dpt: "储配部", note: "测试"},
98
- {title: "盐城市亭湖区大树酒业商行", time: "2024-01-01", person:"01", dpt: "储配部", note: "测试"},
99
- {title: "盐城市亭湖区大树酒业商行", time: "2024-01-02", person:"02", dpt: "储配部", note: "测试"},
100
- {title: "盐城市亭湖区大树酒业商行", time: "2024-01-01", person:"01", dpt: "储配部", note: "测试"},
101
- {title: "盐城市亭湖区大树酒业商行", time: "2024-01-02", person:"02", dpt: "储配部", note: "测试"},
102
- ]
103
- this.list.push(...arr)
104
- this.finished = false
105
- this.offset = this.pageNum * 10
106
- this.pageNum++;
95
+ console.log("lambo-list -- onLoad -- loadData:", this.pageNum)
96
+ setTimeout(() => {
97
+ console.log('this.searchParams',this.searchParams)
98
+ let arr = [
99
+ {title: "盐城市亭湖区大树酒业商行", time: "2024-01-01", person:"01", dpt: "储配部", note: "测试"},
100
+ {title: "盐城市亭湖区大树酒业商行", time: "2024-01-02", person:"02", dpt: "储配部", note: "测试"},
101
+ {title: "盐城市亭湖区大树酒业商行", time: "2024-01-01", person:"01", dpt: "储配部", note: "测试"},
102
+ {title: "盐城市亭湖区大树酒业商行", time: "2024-01-02", person:"02", dpt: "储配部", note: "测试"},
103
+ {title: "盐城市亭湖区大树酒业商行", time: "2024-01-01", person:"01", dpt: "储配部", note: "测试"},
104
+ {title: "盐城市亭湖区大树酒业商行", time: "2024-01-02", person:"02", dpt: "储配部", note: "测试"},
105
+ {title: "盐城市亭湖区大树酒业商行", time: "2024-01-01", person:"01", dpt: "储配部", note: "测试"},
106
+ {title: "盐城市亭湖区大树酒业商行", time: "2024-01-02", person:"02", dpt: "储配部", note: "测试"},
107
+ {title: "盐城市亭湖区大树酒业商行", time: "2024-01-01", person:"01", dpt: "储配部", note: "测试"},
108
+ {title: "盐城市亭湖区大树酒业商行", time: "2024-01-02", person:"02", dpt: "储配部", note: "测试"},
109
+ ]
110
+ this.list.push(...arr)
111
+ this.finished = false
112
+ this.loading = false
113
+ this.offset = this.pageNum * 10
114
+ this.pageNum++;
115
+ }, 1000); // 暂停1秒
116
+
107
117
  }else{
108
118
  let params = {offset: this.offset, limit: this.limit, ...this.searchParams}
109
119
  axios.get(this.url, {params}).then(res => {
@@ -126,14 +136,20 @@ export default {
126
136
  } else {
127
137
  this.finished = true; // 数据加载完毕
128
138
  }
129
- this.loading = false; // 加载状态结束
139
+
130
140
  } else {
131
141
  console.error("lambo-init-list -- onLoad -- 查询[" + this.title + "]数据失败", res)
132
142
  Toast.fail("查询[" + this.title + "]数据失败:" + res.data || '')
143
+ this.error = true;
144
+ this.errorText = res.data
133
145
  }
146
+ this.loading = false; // 加载状态结束
134
147
  }).catch(err => {
135
148
  console.error("lambo-init-list -- onLoad -- 查询[" + this.title + "]异常:", err)
136
149
  Toast.fail("查询[" + this.url + "]数据异常")
150
+ this.error = true;
151
+ this.errorText = err
152
+ this.loading = false; // 加载状态结束
137
153
  })
138
154
  }
139
155
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wl-design-mobile",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "finch",
package/util/jssdk.js CHANGED
@@ -81,51 +81,124 @@ function configWx(){
81
81
  })
82
82
  }
83
83
 
84
+ function configDd(){
85
+ return new Promise((resolve, reject)=>{
86
+ getJsConfig().then((resp)=>{
87
+ //钉钉js-api配置
88
+ console.log("当前页面:"+location.href);
89
+ dd.config({
90
+ agentId:agentId,
91
+ corpId: corpId, // 必填,公众号的唯一标识
92
+ timeStamp: resp.timestamp, // 必填,生成签名的时间戳
93
+ nonceStr: resp.noncestr, // 必填,生成签名的随机串
94
+ signature: resp.signature, // 必填,签名
95
+ jsApiList: [
96
+ 'getDeviceUUID',
97
+ 'getLocation',
98
+
99
+ ] // 必填,需要使用的jsapi列表,注意:不要带dd。
100
+ });
101
+
102
+ dd.ready(() => {
103
+ console.log('初始化钉钉 js-sdk成功');
104
+ resolve()
105
+ });
106
+ dd.error(res => {
107
+ console.log('初始化钉钉 js-sdk失败' + JSON.stringify(res));
108
+ console.log('友情提示:若想成功,则需通过params传参(而不是query)!!!');
109
+ reject('初始化钉钉 js-sdk失败' + JSON.stringify(res))
110
+ });
111
+ }).catch((error)=>{
112
+ reject('请求服务端jssdk签名失败:'+error)
113
+ })
114
+ })
115
+ }
116
+
84
117
  let JsSDK = (function () {
85
118
  function scanQRCode(){
86
119
  return new Promise((resolve, reject) =>{
87
- configWx().then(()=>{
88
- wx.scanQRCode({
89
- desc: 'scanQRCode desc',
90
- needResult: 1,
91
- scanType: ["qrCode", "barCode"],
92
- success: function (resp) {
93
- console.log("resp =>",resp)
94
- let result = resp.resultStr
95
- resolve(result)
120
+ if(getAppType() === '30'){
121
+ dd.scan({
122
+ type: 'all',
123
+ success: (res) => {
124
+ console.log('钉钉扫码结果',res)
125
+ resolve(res.text)
126
+ },
127
+ fail: (err) => {
128
+ console.log('钉钉扫码失败',err)
129
+ reject('钉钉扫码失败:'+err)
96
130
  },
97
- fail: function (res) {
98
- console.log("失败res=>",res)
99
- if (res.errMsg.indexOf('function_not_exist') > 0) {
100
- reject('版本过低请升级');
101
- } else {
102
- reject("扫码失败,请联系系统管理员!");
131
+ complete: () => {},
132
+ });
133
+ }else{
134
+ configWx().then(()=>{
135
+ wx.scanQRCode({
136
+ desc: 'scanQRCode desc',
137
+ needResult: 1,
138
+ scanType: ["qrCode", "barCode"],
139
+ success: function (resp) {
140
+ console.log("微信扫码结果:",resp)
141
+ let result = resp.resultStr
142
+ resolve(result)
143
+ },
144
+ fail: function (res) {
145
+ console.log("失败res=>",res)
146
+ if (res.errMsg.indexOf('function_not_exist') > 0) {
147
+ reject('版本过低请升级');
148
+ } else {
149
+ reject("微信扫码失败,请联系系统管理员!");
150
+ }
103
151
  }
104
- }
152
+ })
153
+ }).catch((error)=>{
154
+ reject('微信扫码失败:'+error)
105
155
  })
106
- }).catch((error)=>{
107
- reject('扫码失败:'+error)
108
- })
156
+ }
109
157
  })
110
158
  }
111
159
  function getLocation(){
112
160
  return new Promise((resolve, reject)=>{
113
- configWx().then(()=>{
114
- wx.getLocation({
115
- type: 'gcj02', //获取gcj02的坐标
116
- success: (res) => {
117
- //res.longitude 获取经度
118
- //res.latitude 获取纬度
119
- console.log(res);
120
- resolve(res)
121
- }, fail: (res) => {
122
- console.log("获取位置失败。"+JSON.stringify(res));
123
- reject("获取位置失败" + JSON.stringify(res))
124
- }
125
- });
126
- }).catch((error)=>{
127
- reject('获取位置失败:'+error)
128
- })
161
+ if(getAppType() === '30'){
162
+ configDd().then(()=>{
163
+ dd.getLocation({
164
+ targetAccuracy: '200',
165
+ cacheTimeout: 20,
166
+ coordinate: '1',
167
+ useCache: true,
168
+ withReGeocode: true,
169
+ type: 1,
170
+ success: (res) => {
171
+ console.log('钉钉获取当前位置结果:', res)
172
+ resolve(res)
173
+ },
174
+ fail: (error) => {
175
+ console.log('钉钉获取位置失败:', error)
176
+ reject('钉钉获取位置失败:'+error)
177
+ },
178
+ complete: () => {},
179
+ })
180
+ }).catch((error)=>{
181
+ reject('钉钉获取位置失败:'+error)
182
+ })
183
+ }else{
184
+ configWx().then(()=>{
185
+ wx.getLocation({
186
+ type: 'gcj02', //获取gcj02的坐标
187
+ success: (res) => {
188
+ //res.longitude 获取经度
189
+ //res.latitude 获取纬度
190
+ console.log(res);
191
+ resolve(res)
192
+ }, fail: (res) => {
193
+ console.log("微信获取位置失败。"+JSON.stringify(res));
194
+ reject("微信获取位置失败" + JSON.stringify(res))
195
+ }
196
+ });
197
+ }).catch((error)=>{
198
+ reject('微信获取位置失败:'+error)
199
+ })
200
+ }
201
+
129
202
  })
130
203
  }
131
204