@xtdev/xt-miniprogram-ui 1.0.9 → 1.0.12

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.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/libs/xt-button/index.js +52 -0
  3. package/libs/xt-button/index.json +6 -0
  4. package/libs/xt-button/index.wxml +9 -0
  5. package/libs/xt-button/index.wxss +76 -0
  6. package/libs/xt-card-cell/README.md +65 -0
  7. package/libs/xt-card-cell/index.wxss +1 -0
  8. package/libs/xt-dialog/README.md +152 -0
  9. package/libs/xt-dialog/index.js +126 -0
  10. package/libs/xt-dialog/index.json +4 -0
  11. package/libs/xt-dialog/index.wxml +51 -0
  12. package/libs/xt-dialog/index.wxss +121 -0
  13. package/libs/xt-icon/README.md +39 -0
  14. package/libs/xt-icon/index.wxss +24 -46
  15. package/libs/xt-search/README.md +55 -0
  16. package/libs/xt-search/index.js +0 -37
  17. package/libs/xt-search/index.wxml +7 -7
  18. package/libs/xt-search/index.wxss +3 -3
  19. package/libs/xt-stepper/README.md +52 -0
  20. package/libs/xt-stepper/index.js +158 -0
  21. package/libs/xt-stepper/index.json +4 -0
  22. package/libs/xt-stepper/index.wxml +11 -0
  23. package/libs/xt-stepper/index.wxss +83 -0
  24. package/libs/xt-steps/README.md +61 -0
  25. package/libs/xt-steps/index.js +37 -0
  26. package/libs/xt-steps/index.json +7 -0
  27. package/libs/xt-steps/index.wxml +32 -0
  28. package/libs/xt-steps/index.wxss +180 -0
  29. package/libs/xt-tag/README.md +65 -0
  30. package/libs/xt-tag/index.js +38 -0
  31. package/libs/xt-tag/index.json +6 -0
  32. package/libs/xt-tag/index.wxml +5 -0
  33. package/libs/xt-tag/index.wxss +36 -0
  34. package/libs/xt-toast/README.md +65 -0
  35. package/libs/xt-toast/index.js +77 -0
  36. package/libs/xt-toast/index.json +6 -0
  37. package/libs/xt-toast/index.wxml +7 -0
  38. package/libs/xt-toast/index.wxss +26 -0
  39. package/libs/xt-uploader/README.md +44 -0
  40. package/libs/xt-uploader/index.js +150 -0
  41. package/libs/xt-uploader/index.json +6 -0
  42. package/libs/xt-uploader/index.wxml +16 -0
  43. package/libs/xt-uploader/index.wxss +66 -0
  44. package/libs/xt-uploader/utils.js +164 -0
  45. package/package.json +3 -12
  46. package/bin/index.js +0 -62
  47. package/template/list/index.js +0 -81
  48. package/template/list/index.json +0 -6
  49. package/template/list/index.wxml +0 -17
  50. package/template/list/index.wxss +0 -24
@@ -0,0 +1,44 @@
1
+ # Icon图标
2
+
3
+ ### 介绍
4
+ 用于表单列表上传图片
5
+
6
+ ###效果图
7
+ ![效果图](https://img.tanjiu.cn/home/p4fiMjw3F7ssMNhQxafHCnsn8ZZ8m67Q.png "列表uploader效果图")
8
+
9
+ ### 引入
10
+ 在app.json或页面配置json中引入
11
+ ```
12
+ "usingComponents": {
13
+ "xt-uploader": "@xtdev/xt-miniprogram-ui/xt-uploader",
14
+ }
15
+ ```
16
+
17
+ ## 代码演示
18
+
19
+ ### 基础用法
20
+
21
+ ```
22
+ <xt-uploader title="标题标题"></xt-uploader>
23
+ ```
24
+
25
+ ##API
26
+
27
+ ####xt-tag props
28
+
29
+ | 参数 | 说明 | 类型 |
30
+ | ----------- | ----------- | ---------- |
31
+ | fileList | 图片列表,必传,受控组件 | `Array<String>` |
32
+ | title | 表单标题 | `String` |
33
+ | max | 上传最大值,默认为9 | `Number` |
34
+ | uploadDesc | 上传文案说明 | `String` |
35
+ | customUpload | 是否自定义上传,true 点击盒子触发upload | `Boolean` |
36
+ | disabled | 是否禁用,禁用时不能删除和上传,可预览 | `Boolean` |
37
+ | sourceType | 照片来源 | ["album", "camera"] |
38
+
39
+ ####Events
40
+
41
+ | 事件名 | 说明 | 回调参数 |
42
+ | ---------------- | ------------- | ---------------------- |
43
+ | bind:upload | 上传成功后触发,如果customUpload为true则点击上传及触发 | fileList:图片列表, url:当前上传图片地址 |
44
+ | bind:delete | 删除成功后触发 | fileList:图片列表, url:当前删除图片地址,index:当前删除图片索引 |
@@ -0,0 +1,150 @@
1
+ // src/xt-uploader/index.js
2
+ import utils from "./utils";
3
+ Component({
4
+ /**
5
+ * 组件的属性列表
6
+ */
7
+ properties: {
8
+ title: {
9
+ type: String,
10
+ value: "",
11
+ },
12
+ fileList: {
13
+ type: Array,
14
+ value: [],
15
+ },
16
+ max: {
17
+ type: Number,
18
+ value: 9,
19
+ },
20
+ uploadDesc: {
21
+ type: String,
22
+ value: "",
23
+ },
24
+ // ["album", "camera"]
25
+ sourceType: {
26
+ type: Array,
27
+ value: ["camera"],
28
+ },
29
+ customUpload: {
30
+ type: Boolean,
31
+ value: false,
32
+ },
33
+ disabled: {
34
+ type: Boolean,
35
+ value: false,
36
+ },
37
+ },
38
+
39
+ /**
40
+ * 组件的初始数据
41
+ */
42
+ data: {},
43
+
44
+ /**
45
+ * 组件的方法列表
46
+ */
47
+ methods: {
48
+ // 预览
49
+ onPreviewImage(e) {
50
+ const url = e.target.dataset.url;
51
+ // const index = e.target.dataset.index;
52
+ wx.previewImage({
53
+ urls: this.properties.fileList,
54
+ current: url,
55
+ });
56
+ },
57
+ // 删除
58
+ onDelete(e) {
59
+ const url = e.currentTarget.dataset.url;
60
+ const index = e.currentTarget.dataset.index;
61
+ this.properties.fileList.splice(index, 1);
62
+ this.triggerEvent("delete", {
63
+ fileList: this.properties.fileList,
64
+ url,
65
+ index,
66
+ });
67
+ },
68
+ // 上传成功
69
+ onUploadSuccess(url) {
70
+ this.triggerEvent("upload", { fileList: this.properties.fileList, url });
71
+ },
72
+ // 点击上传
73
+ startTakePhoto() {
74
+ const _this = this;
75
+ if (this.properties.customUpload) {
76
+ this.triggerEvent("upload", {});
77
+ return;
78
+ }
79
+ wx.chooseMedia({
80
+ count: 1,
81
+ mediaType: ["image"],
82
+ sizeType: ["compressed"],
83
+ sourceType: this.properties.sourceType,
84
+ success(res) {
85
+ console.log(res, "0000");
86
+ // tempFilePath可以作为img标签的src属性显示图片
87
+ const tempFilePaths = res.tempFiles[0].tempFilePath;
88
+ _this.uploadImage_v(tempFilePaths);
89
+ },
90
+ fail(error) {
91
+ wx.showToast({
92
+ title: error?.errMsg,
93
+ icon: "none",
94
+ });
95
+ },
96
+ });
97
+ },
98
+ // 上传文件
99
+ uploadImage_v(filePaths) {
100
+ let _this = this;
101
+ const { fileList } = _this.properties;
102
+ wx.showLoading("图片上传中");
103
+ utils.newHttp(
104
+ "/core/file/oss/miniProgramPolicy",
105
+ "GET",
106
+ {
107
+ dir: "microComponents",
108
+ },
109
+ (res) => {
110
+ const { host, signature, accessKeyId, policy, dir } = res.data;
111
+ let path = filePaths;
112
+ let name = utils.random_string(32) + utils.get_suffix(path);
113
+ wx.uploadFile({
114
+ url: host,
115
+ filePath: filePaths,
116
+ name: "file",
117
+ formData: {
118
+ key: dir + "/" + name,
119
+ policy,
120
+ success_action_status: "200",
121
+ OSSAccessKeyId: accessKeyId,
122
+ signature,
123
+ },
124
+ header: {
125
+ "Content-Type": "multipart/form-data",
126
+ "wow-token": "c9fbecb5fdeecb78e8745db9225d88e1",
127
+ },
128
+ success: (res) => {
129
+ if (res.statusCode == 200) {
130
+ let url = host + dir + "/" + name;
131
+ fileList.push(url);
132
+ _this.onUploadSuccess(url);
133
+ wx.showToast({
134
+ icon: "success",
135
+ title: "上传成功",
136
+ });
137
+ }
138
+ },
139
+ fail: (err) => {
140
+ wx.showToast({
141
+ icon: "error",
142
+ title: err.errMsg || "网络错误,请重试",
143
+ });
144
+ },
145
+ });
146
+ }
147
+ );
148
+ },
149
+ },
150
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "xt-icon": "../xt-icon/index"
5
+ }
6
+ }
@@ -0,0 +1,16 @@
1
+ <!-- src/xt-uploader/index.wxml -->
2
+ <view class="xt-uploader">
3
+ <view class="title_text" wx:if="{{title}}">{{title}}</view>
4
+ <view class="file_box">
5
+ <view wx:for="{{fileList}}" wx:key="index" class="file_item">
6
+ <image class="file_img" src="{{item}}" mode="aspectFit" bindtap="onPreviewImage" data-url="{{item}}" data-index="{{index}}" />
7
+ <view class="close_box" bindtap="onDelete" data-url="{{item}}" data-index="{{index}}" wx:if="{{!disabled}}">
8
+ <xt-icon icon="shanchu" size="48"></xt-icon>
9
+ </view>
10
+ </view>
11
+ <view class="file_item" wx:if="{{!disabled && fileList.length<max}}" bindtap="startTakePhoto">
12
+ <image src="https://img.tanjiu.cn/home/DDDsrH7PpNhneQsXGFmGGPcSM3QYXG8N.png" class="camera_icon" />
13
+ <view wx:if="{{uploadDesc}}" class="upload_desc">{{uploadDesc}}</view>
14
+ </view>
15
+ </view>
16
+ </view>
@@ -0,0 +1,66 @@
1
+ /* src/xt-uploader/index.wxss */
2
+ .xt-uploader {
3
+ background-color : #fff;
4
+ /* padding : 32rpx;
5
+ padding-bottom : 0; */
6
+ }
7
+
8
+ .title_text {
9
+ line-height: 48rpx;
10
+ font-size : 34rpx;
11
+ font-family: PingFang SC-Semibold,
12
+ PingFang SC;
13
+ font-weight : 800;
14
+ color : #000000;
15
+ margin-bottom: 16rpx;
16
+ }
17
+
18
+ .file_box {
19
+ display : flex;
20
+ flex-wrap: wrap;
21
+ }
22
+
23
+ .file_item {
24
+ width : 196rpx;
25
+ height : 196rpx;
26
+ border-radius : 8rpx;
27
+ overflow : hidden;
28
+ position : relative;
29
+ display : flex;
30
+ flex-direction : column;
31
+ justify-content : center;
32
+ align-items : center;
33
+ background-color: #F5F5F5;
34
+ margin-bottom : 32rpx;
35
+ }
36
+
37
+ .file_item:not(:last-child) {
38
+ margin-right: 32rpx;
39
+ }
40
+
41
+ .camera_icon {
42
+ width : 80rpx;
43
+ height: 80rpx;
44
+ }
45
+
46
+ .file_img {
47
+ width : 196rpx;
48
+ height: 196rpx;
49
+ }
50
+
51
+ .close_box {
52
+ position: absolute;
53
+ top : 0;
54
+ right : 0;
55
+ color : rgba(0, 0, 0, 0.5);
56
+ }
57
+
58
+ .upload_desc {
59
+ line-height: 40rpx;
60
+ font-size : 28rpx;
61
+ font-family: PingFang SC-Regular,
62
+ PingFang SC;
63
+ font-weight: 400;
64
+ color : #727272;
65
+ margin-top : 8rpx;
66
+ }
@@ -0,0 +1,164 @@
1
+ // import md5 from "md5";
2
+
3
+ function newhttpV1(url, method, params, callBack, header) {
4
+ var timestamp = Date.parse(new Date());
5
+ var date = new Date(timestamp);
6
+ //获取年份
7
+ var Y = date.getFullYear();
8
+ //获取月份
9
+ var M =
10
+ date.getMonth() + 1 < 10
11
+ ? "0" + (date.getMonth() + 1)
12
+ : date.getMonth() + 1;
13
+ //获取当日日期
14
+ var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
15
+ var currentDate = Y + "-" + M + "-" + D;
16
+
17
+ //后端验证授权的字符串
18
+ var pass =
19
+ "MIIBOjANBgkqhkiG9w0BAQEFAAOCAScAMIIBIgKCARkA2a6BXaPViAbEvAPn3qtB" +
20
+ currentDate;
21
+
22
+ //change - gml 接口url拼接
23
+ var full_url = "https://gateway.tanjiu.cn" + url;
24
+ // 请求的唯一性
25
+ let onlySign = url + JSON.stringify(params);
26
+ if (getApp().hasQKey(onlySign)) {
27
+ return;
28
+ }
29
+ wx.request({
30
+ url: full_url,
31
+ method: method,
32
+ header: {
33
+ "content-type": "application/json",
34
+ // Authorization: md5(pass),
35
+ "ls-client-id": "TANJIUCLOUD_BUSINESS",
36
+ token: "openApi",
37
+ // xtoken: getApp().globalData?.xtoken,
38
+ "x-login-session": JSON.stringify({ userId: "2022199" }),
39
+ // xtoken: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOjc0NDkwMjM1NjQ2MjMzODA0OCwicm5TdHIiOiJoT3ZoUVVxMjM3SUtDelpPN0dXb09jdnA2ZGdIV1g2byIsImF1dGhUb2tlbkJvIjp7Imd1aWQiOjc0NDkwMjM1NjQ2MjMzODA0OCwicGxhdGZvcm1Vc2VySWQiOjE1NTYwODA3ODE0Mjg1NzIxNiwiYXBwQ29kZSI6IlRBTl9TQUxFU01BTiIsInBsYXRmb3JtQ2xpZW50VHlwZSI6IldFQ0hBVF9BUFBMRVRTIiwicGxhdGZvcm1DbGllbnRDb2RlIjoiV0VDSEFUX0FQUExFVFNfVEFOX1NBTEVTTUFOIiwid2VhdmVyVXNlck5hbWUiOiJlbnRlcnByaXNlX3dlY2hhdF8zNl94dXp1byIsInRlbmFudElkIjoxLCJlbnYiOiJ0ZXN0In0sIm9wZW5pZCI6Im9mODFMNU9jVGduMHNnRDBKQlpTZFpRcnZ4ZlEiLCJ1bmlvbmlkIjoib3BVLUQwb1E4RjBQUTY0NnpSREpIRG1sMzJMQSIsImlhdCI6MTY3NjQ1MzQ1OTE3NiwiZXhwIjoxNjc3MDU4MjU5MTc2LCJ0b2tlbklkIjoiZmQ0M2U0MjIxYjJjNDVkN2EyYWJhNTdkZTNhNGY1NmEifQ.weXKWnX7sWmL7f1s2a2MuOKZd5Yw8elzrG824JY0R-4',
40
+ ...header,
41
+ },
42
+ data: params,
43
+ success(res) {
44
+ if (res.data) {
45
+ var result = {
46
+ data: res.data.data,
47
+ message: res.data.message || res.data.errMsg,
48
+ code:
49
+ res.data.code ||
50
+ res.data.errCode ||
51
+ (res.data.code === 0 || res.data.errCode == 0 ? 0 : null),
52
+ };
53
+ callBack(result);
54
+ }
55
+ },
56
+ fail(err) {
57
+ var result = {
58
+ success: false,
59
+ data: {},
60
+ message: err.errMsg || err.msg || err.message,
61
+ };
62
+ wx.showToast({
63
+ title: esult.message || "请检查网络是否通畅,稍后重试!",
64
+ icon: "none",
65
+ });
66
+ console.log("err = ", err);
67
+ callBack(result);
68
+ },
69
+ complete() {
70
+ getApp().delQKey(onlySign);
71
+ },
72
+ });
73
+ getApp().createQKey(onlySign);
74
+ }
75
+
76
+ function newhttpRequest(url, method, params, callBack, header) {
77
+ var timestamp = Date.parse(new Date());
78
+ var date = new Date(timestamp);
79
+ //获取年份
80
+ var Y = date.getFullYear();
81
+ //获取月份
82
+ var M =
83
+ date.getMonth() + 1 < 10
84
+ ? "0" + (date.getMonth() + 1)
85
+ : date.getMonth() + 1;
86
+ //获取当日日期
87
+ var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
88
+ var currentDate = Y + "-" + M + "-" + D;
89
+
90
+ //后端验证授权的字符串
91
+ var pass =
92
+ "MIIBOjANBgkqhkiG9w0BAQEFAAOCAScAMIIBIgKCARkA2a6BXaPViAbEvAPn3qtB" +
93
+ currentDate;
94
+
95
+ //change - gml 接口url拼接
96
+ var full_url = "https://gateway.tanjiu.cn" + url;
97
+ wx.request({
98
+ url: full_url,
99
+ method: method,
100
+ header: {
101
+ "content-type": "application/json",
102
+ // Authorization: md5(pass),
103
+ "ls-client-id": "TANJIUCLOUD_BUSINESS",
104
+ token: "openApi",
105
+ "x-login-session": JSON.stringify({ userId: "2022199" }),
106
+ ...header,
107
+ },
108
+ data: params,
109
+ success(res) {
110
+ if (res.data) {
111
+ var result = {
112
+ data: res.data.data || res.data.retdata || res,
113
+ message: res.data.message || res.data.errMsg,
114
+ code:
115
+ res.data.code ||
116
+ res.data.errCode ||
117
+ (res.data.code == 0 || res.data.errCode == 0 ? 0 : null),
118
+ };
119
+ callBack(result);
120
+ }
121
+ },
122
+ fail(err) {
123
+ var result = {
124
+ success: false,
125
+ data: {},
126
+ message: err.errMsg || err.msg,
127
+ };
128
+ wx.showToast({
129
+ title: esult.message || "请检查网络是否通畅,稍后重试!",
130
+ icon: "none",
131
+ });
132
+ console.log("err = ", err);
133
+ callBack(result);
134
+ },
135
+ });
136
+ }
137
+
138
+ function random_string(len) {
139
+ len = len || 32;
140
+ let chars = "ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678";
141
+ let maxPos = chars.length;
142
+ let pwd = "";
143
+ for (let i = 0; i < len; i++) {
144
+ pwd += chars.charAt(Math.floor(Math.random() * maxPos));
145
+ }
146
+ return pwd;
147
+ }
148
+
149
+ // 解密
150
+ function get_suffix(filename) {
151
+ console.log(filename, "filename");
152
+ let pos = filename.lastIndexOf(".");
153
+ let suffix = "";
154
+ if (pos != -1) {
155
+ suffix = filename.substring(pos);
156
+ }
157
+ return suffix;
158
+ }
159
+
160
+ export default {
161
+ newHttp: newhttpRequest,
162
+ random_string,
163
+ get_suffix,
164
+ };
package/package.json CHANGED
@@ -1,10 +1,7 @@
1
1
  {
2
2
  "name": "@xtdev/xt-miniprogram-ui",
3
- "version": "1.0.9",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
- "bin": {
6
- "xt-page-cli": "bin/index.js"
7
- },
8
5
  "miniprogram": "libs",
9
6
  "publishConfig": {
10
7
  "access": "public",
@@ -12,16 +9,13 @@
12
9
  },
13
10
  "files": [
14
11
  "libs",
15
- "bin",
16
- "template",
17
12
  "README.md"
18
13
  ],
19
14
  "scripts": {
20
15
  "test": "echo \"Error: no test specified\" && exit 1",
21
16
  "dev": "gulp",
22
17
  "build": "gulp build",
23
- "release": "yarn version --patch && yarn build && npm publish --access public --registry=https://registry.npmjs.org",
24
- "cli:demo": "xt-page-cli create list"
18
+ "release": "yarn version --patch && yarn build && npm publish --access public --registry=https://registry.npmjs.org"
25
19
  },
26
20
  "repository": {
27
21
  "type": "git",
@@ -30,15 +24,12 @@
30
24
  "author": "",
31
25
  "license": "ISC",
32
26
  "devDependencies": {
33
- "chalk": "^4.0.0",
34
- "commander": "^10.0.1",
35
27
  "del": "^3.0.0",
36
28
  "gulp": "^4.0.2",
37
29
  "gulp-changed": "^4.0.3",
38
30
  "gulp-clean": "^0.4.0",
39
31
  "gulp-json-transform": "^0.4.8",
40
- "gulp-rename": "^2.0.0",
41
- "mkdirp": "^3.0.1"
32
+ "gulp-rename": "^2.0.0"
42
33
  },
43
34
  "dependencies": {}
44
35
  }
package/bin/index.js DELETED
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const program = require('commander');
4
- const path = require('path');
5
- const chalk = require('chalk');
6
- const mkdirp = require('mkdirp');
7
- const { readFileSync, existsSync, readdirSync, statSync, createReadStream, createWriteStream, writeFileSync } = require('fs');
8
- chalk.enabled = true
9
- /**
10
- * 拷贝文件夹下的文件到指定位置
11
- * @param {*} sourceDir
12
- * @param {*} destDir
13
- */
14
- function copyFiles(sourceDir, destDir) {
15
- // 确保目标文件夹存在,如果不存在则创建它
16
- mkdirp.sync(destDir);
17
- const filenames = readdirSync(sourceDir);
18
- filenames.forEach(function (filename) {
19
- const sourceFile = path.join(sourceDir, filename);
20
- const destFile = path.join(destDir, filename);
21
- const stat = statSync(sourceFile);
22
- if (stat.isDirectory()) {
23
- // 如果当前文件是一个文件夹,则递归拷贝该文件夹下所有文件
24
- copyFiles(sourceFile, destFile);
25
- } else {
26
- // 如果当前文件是一个普通文件,则复制文件到目标文件夹
27
- const reader = createReadStream(sourceFile);
28
- const writer = createWriteStream(destFile);
29
- reader.pipe(writer);
30
- }
31
- });
32
- }
33
- // 新增创建
34
- program.command('create <template-name>')
35
- .description('根据模板名称,快速构建页面模板')
36
- .action(async (templateName) => {
37
- console.log('🎉 开始构建');
38
- if (!templateName) {
39
- console.error(chalk.red.dim('请填写模板名称'));
40
- return;
41
- }
42
- // const tempFolder = `/template/${templateName}`;
43
- const tempFolder = path.join(__dirname, '..', `./template/${templateName}`);
44
- console.log(tempFolder);
45
- const tempExist = existsSync(`${tempFolder}/index.js`);
46
- if (!tempExist) {
47
- console.error(chalk.red.dim('请填写正确的模板名称'));
48
- return;
49
- }
50
- console.log('📋 开始拷贝');
51
- copyFiles(tempFolder, process.cwd());
52
- console.log('✅ 拷贝完成');
53
- console.log('🔄 更改json引入路径');
54
- const jsonPath = path.join(process.cwd(), './index.json');
55
- // 延迟一秒读取文件
56
- await new Promise(resolve => setTimeout(resolve, 1000))
57
- const data = readFileSync(jsonPath);
58
- const result = data.toString('utf-8').replace(/\.\.\/\.\.\/libs/g, '@xtdev/xt-miniprogram-ui');
59
- writeFileSync(jsonPath, result, 'utf-8');
60
- console.log('🎉 创建完成');
61
- });
62
- program.parse(process.argv);
@@ -1,81 +0,0 @@
1
- // template/index.js
2
- Page({
3
-
4
- /**
5
- * 页面的初始数据
6
- */
7
- data: {
8
- page: {
9
- isLoading: false,
10
- size: 10,
11
- over: false,
12
- curPage: 0
13
- },
14
- list: []
15
- },
16
-
17
- /**
18
- * 生命周期函数--监听页面加载
19
- */
20
- onLoad(options) {
21
- this.getListData();
22
- },
23
- handleSearch(e) {
24
- console.log(e.detail);
25
- this.setData({
26
- page: {
27
- isLoading: false,
28
- size: 10,
29
- over: false,
30
- curPage: 0
31
- }
32
- })
33
- this.getListData(true);
34
- },
35
- async getListData(refresh = false) {
36
- const { isLoading, curPage, size } = this.data.page;
37
- if (isLoading) return;
38
- wx.showLoading();
39
- this.setData({
40
- 'page.isLoading': true,
41
- 'page.curPage': curPage + 1
42
- })
43
- // 模拟接口请求,开发请切换成真实数据
44
- const data = await new Promise(resolve => {
45
- setTimeout(() => {
46
- const temp = new Array(size).fill(1).map(num => ({
47
- title: '北京老布鞋烟酒店',
48
- subTitle: '合作中',
49
- subTitleColor: '#6722ab',
50
- state: 20,
51
- dataList: [{
52
- label: '店老板名称',
53
- valueType: 'text',
54
- value: '张三',
55
- }, {
56
- label: '联系电话',
57
- valueType: 'tel',
58
- value: '18080166584',
59
- }, {
60
- label: '报销金',
61
- valueType: 'text',
62
- value: '3000元',
63
- }]
64
- }));
65
- resolve(temp);
66
- }, 2000);
67
- })
68
- const list = refresh ? data : this.data.list.concat(data);
69
- this.setData({
70
- list,
71
- 'page.isLoading': false,
72
- 'page.over': list.length > 10
73
- })
74
- wx.hideLoading();
75
- },
76
- onReachBottom() {
77
- if (!this.data.page.over) {
78
- this.getListData();
79
- }
80
- }
81
- })
@@ -1,6 +0,0 @@
1
- {
2
- "usingComponents": {
3
- "xt-card-cell": "../../libs/xt-card-cell",
4
- "xt-search": "../../libs/xt-search"
5
- }
6
- }
@@ -1,17 +0,0 @@
1
- <view class="search-content">
2
- <xt-search bind:onSearch="handleSearch"></xt-search>
3
- </view>
4
- <view wx:for="{{list}}" wx:key="id">
5
- <xt-card-cell item="{{item}}">
6
- <view slot="card-footer">
7
- <!-- 列表按钮 -->
8
- <view class="footer">
9
- <view class="default-btn">
10
- 查看详情
11
- </view>
12
- </view>
13
- </view>
14
- </xt-card-cell>
15
- </view>
16
- <view wx:if="{{page.over}}" class="bottom-tips">没有更多数据</view>
17
- <view wx:elif="{{page.isLoading && list.length}}" class="bottom-tips">加载中...</view>
@@ -1,24 +0,0 @@
1
- page{
2
- background-color: #f2f2f2;
3
- padding: 24rpx;
4
- box-sizing: border-box;
5
- }
6
- .search-content{
7
- margin-bottom: 24rpx;
8
- }
9
- .default-btn {
10
- display: inline-block;
11
- color: #6722AB;
12
- border: 2rpx solid #6722AB;
13
- box-sizing: border-box;
14
- border-radius: 120rpx;
15
- margin-top: 32rpx;
16
- font-size: 34rpx;
17
- line-height: 48rpx;
18
- font-weight: 800;
19
- padding: 16rpx 32rpx;
20
- }
21
- .bottom-tips{
22
- text-align: center;
23
- padding: 20px;
24
- }