正在显示
37 个修改的文件
包含
3381 行增加
和
648 行删除
@@ -14,7 +14,6 @@ | @@ -14,7 +14,6 @@ | ||
14 | console.log('获取code'); | 14 | console.log('获取code'); |
15 | getApp().authorization() | 15 | getApp().authorization() |
16 | } else if (e.query.code) { | 16 | } else if (e.query.code) { |
17 | - console.log(2); | ||
18 | getApp().getOpenid(e.query.code) | 17 | getApp().getOpenid(e.query.code) |
19 | } | 18 | } |
20 | // else { | 19 | // else { |
@@ -106,7 +105,12 @@ | @@ -106,7 +105,12 @@ | ||
106 | display: flex; | 105 | display: flex; |
107 | align-items: center; | 106 | align-items: center; |
108 | } | 107 | } |
109 | - | 108 | + .flexbetom { |
109 | + flex: 1; | ||
110 | + display: flex; | ||
111 | + align-items: center; | ||
112 | + justify-content: space-between; | ||
113 | + } | ||
110 | .fw700 { | 114 | .fw700 { |
111 | font-weight: 700; | 115 | font-weight: 700; |
112 | } | 116 | } |
@@ -48,6 +48,9 @@ export const sort_list = (data) => request({url: 'arc/sort_list',method: 'post' | @@ -48,6 +48,9 @@ export const sort_list = (data) => request({url: 'arc/sort_list',method: 'post' | ||
48 | export const arc_list = (data) => request({url: 'arc/arc_list',method: 'post',data: data}) | 48 | export const arc_list = (data) => request({url: 'arc/arc_list',method: 'post',data: data}) |
49 | 49 | ||
50 | // 详情资讯 | 50 | // 详情资讯 |
51 | -export const arc_detail = (arc_id) => request({url: 'arc/arc_detail',method: 'post',data: {arc_id}}) | 51 | +export const arc_detail = (arc_id,url) => request({url: 'arc/arc_detail',method: 'post',data: {arc_id,url}}) |
52 | // 全部分类 | 52 | // 全部分类 |
53 | -export const sort_all = (keyword) => request({url: 'product/sort_all',method: 'post',data: {keyword}}) | ||
53 | +export const sort_all = (keyword) => request({url: 'product/sort_all',method: 'post',data: {keyword}}) | ||
54 | + | ||
55 | +//搜索弹窗分类 | ||
56 | +export const sort_search = (keyword) => request({url: 'product/sort_search',method: 'post',data: {keyword}}) |
1 | +<template> | ||
2 | + <!--增加audio标签支持--> | ||
3 | + <audio | ||
4 | + :id="node.attr.id" | ||
5 | + :class="node.classStr" | ||
6 | + :style="node.styleStr" | ||
7 | + :src="node.attr.src" | ||
8 | + :loop="node.attr.loop" | ||
9 | + :poster="node.attr.poster" | ||
10 | + :name="node.attr.name" | ||
11 | + :author="node.attr.author" | ||
12 | + controls></audio> | ||
13 | +</template> | ||
14 | + | ||
15 | +<script> | ||
16 | +export default { | ||
17 | + name: 'wxParseAudio', | ||
18 | + props: { | ||
19 | + node: { | ||
20 | + type: Object, | ||
21 | + default() { | ||
22 | + return {}; | ||
23 | + }, | ||
24 | + }, | ||
25 | + }, | ||
26 | +}; | ||
27 | +</script> |
components/u-parse/components/wxParseImg.vue
0 → 100644
1 | +<template> | ||
2 | + <image | ||
3 | + :mode="node.attr.mode" | ||
4 | + :lazy-load="node.attr.lazyLoad" | ||
5 | + :class="node.classStr" | ||
6 | + :style="newStyleStr || node.styleStr" | ||
7 | + :data-src="node.attr.src" | ||
8 | + :src="node.attr.src" | ||
9 | + @tap="wxParseImgTap" | ||
10 | + @load="wxParseImgLoad" | ||
11 | + /> | ||
12 | +</template> | ||
13 | + | ||
14 | +<script> | ||
15 | +export default { | ||
16 | + name: 'wxParseImg', | ||
17 | + data() { | ||
18 | + return { | ||
19 | + newStyleStr: '', | ||
20 | + preview: true, | ||
21 | + }; | ||
22 | + }, | ||
23 | + props: { | ||
24 | + node: { | ||
25 | + type: Object, | ||
26 | + default() { | ||
27 | + return {}; | ||
28 | + }, | ||
29 | + }, | ||
30 | + }, | ||
31 | + methods: { | ||
32 | + wxParseImgTap(e) { | ||
33 | + if (!this.preview) return; | ||
34 | + const { src } = e.currentTarget.dataset; | ||
35 | + if (!src) return; | ||
36 | + let parent = this.$parent; | ||
37 | + while(!parent.preview || typeof parent.preview !== 'function') {// TODO 遍历获取父节点执行方法 | ||
38 | + parent = parent.$parent; | ||
39 | + } | ||
40 | + parent.preview(src, e); | ||
41 | + }, | ||
42 | + // 图片视觉宽高计算函数区 | ||
43 | + wxParseImgLoad(e) { | ||
44 | + const { src } = e.currentTarget.dataset; | ||
45 | + if (!src) return; | ||
46 | + const { width, height } = e.mp.detail; | ||
47 | + const recal = this.wxAutoImageCal(width, height); | ||
48 | + const { imageheight, imageWidth } = recal; | ||
49 | + const { padding, mode } = this.node.attr; | ||
50 | + const { styleStr } = this.node; | ||
51 | + const imageHeightStyle = mode === 'widthFix' ? '' : `height: ${imageheight}px;`; | ||
52 | + this.newStyleStr = `${styleStr}; ${imageHeightStyle}; width: ${imageWidth}px; padding: 0 ${+padding}px;`; | ||
53 | + }, | ||
54 | + // 计算视觉优先的图片宽高 | ||
55 | + wxAutoImageCal(originalWidth, originalHeight) { | ||
56 | + // 获取图片的原始长宽 | ||
57 | + const { padding } = this.node.attr; | ||
58 | + const windowWidth = this.node.$screen.width - (2 * padding); | ||
59 | + const results = {}; | ||
60 | + | ||
61 | + if (originalWidth < 60 || originalHeight < 60) { | ||
62 | + const { src } = this.node.attr; | ||
63 | + let parent = this.$parent; | ||
64 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
65 | + parent = parent.$parent; | ||
66 | + } | ||
67 | + parent.removeImageUrl(src); | ||
68 | + this.preview = false; | ||
69 | + } | ||
70 | + | ||
71 | + // 判断按照那种方式进行缩放 | ||
72 | + if (originalWidth > windowWidth) { | ||
73 | + // 在图片width大于手机屏幕width时候 | ||
74 | + results.imageWidth = windowWidth; | ||
75 | + results.imageheight = windowWidth * (originalHeight / originalWidth); | ||
76 | + } else { | ||
77 | + // 否则展示原来的数据 | ||
78 | + results.imageWidth = originalWidth; | ||
79 | + results.imageheight = originalHeight; | ||
80 | + } | ||
81 | + | ||
82 | + return results; | ||
83 | + }, | ||
84 | + }, | ||
85 | +}; | ||
86 | +</script> |
1 | +<template> | ||
2 | + <view> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <block v-if="node.tag == 'button'"> | ||
6 | + <button type="default" size="mini"> | ||
7 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
8 | + <wx-parse-template :node="node" /> | ||
9 | + </block> | ||
10 | + </button> | ||
11 | + </block> | ||
12 | + | ||
13 | + <!--li类型--> | ||
14 | + <block v-else-if="node.tag == 'li'"> | ||
15 | + <view :class="node.classStr" :style="node.styleStr"> | ||
16 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
17 | + <wx-parse-template :node="node" /> | ||
18 | + </block> | ||
19 | + </view> | ||
20 | + </block> | ||
21 | + | ||
22 | + <!--video类型--> | ||
23 | + <block v-else-if="node.tag == 'video'"> | ||
24 | + <wx-parse-video :node="node" /> | ||
25 | + </block> | ||
26 | + | ||
27 | + <!--audio类型--> | ||
28 | + <block v-else-if="node.tag == 'audio'"> | ||
29 | + <wx-parse-audio :node="node" /> | ||
30 | + </block> | ||
31 | + | ||
32 | + <!--img类型--> | ||
33 | + <block v-else-if="node.tag == 'img'"> | ||
34 | + <wx-parse-img :node="node" /> | ||
35 | + </block> | ||
36 | + | ||
37 | + <!--a类型--> | ||
38 | + <block v-else-if="node.tag == 'a'"> | ||
39 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
40 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
41 | + <wx-parse-template :node="node" /> | ||
42 | + </block> | ||
43 | + </view> | ||
44 | + </block> | ||
45 | + | ||
46 | + <!--table类型--> | ||
47 | + <block v-else-if="node.tag == 'table'"> | ||
48 | + <view :class="node.classStr" class="table" :style="node.styleStr"> | ||
49 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
50 | + <wx-parse-template :node="node" /> | ||
51 | + </block> | ||
52 | + </view> | ||
53 | + </block> | ||
54 | + | ||
55 | + <!--br类型--> | ||
56 | + <block v-else-if="node.tag == 'br'"> | ||
57 | + <text>\n</text> | ||
58 | + </block> | ||
59 | + | ||
60 | + <!--其他标签--> | ||
61 | + <block v-else> | ||
62 | + <view :class="node.classStr" :style="node.styleStr"> | ||
63 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
64 | + <wx-parse-template :node="node" /> | ||
65 | + </block> | ||
66 | + </view> | ||
67 | + </block> | ||
68 | + | ||
69 | + </block> | ||
70 | + | ||
71 | + <!--判断是否是文本节点--> | ||
72 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
73 | + </view> | ||
74 | +</template> | ||
75 | + | ||
76 | +<script> | ||
77 | + import wxParseTemplate from './wxParseTemplate1'; | ||
78 | + import wxParseImg from './wxParseImg'; | ||
79 | + import wxParseVideo from './wxParseVideo'; | ||
80 | + import wxParseAudio from './wxParseAudio'; | ||
81 | + | ||
82 | + export default { | ||
83 | + name: 'wxParseTemplate0', | ||
84 | + props: { | ||
85 | + node: {}, | ||
86 | + }, | ||
87 | + components: { | ||
88 | + wxParseTemplate, | ||
89 | + wxParseImg, | ||
90 | + wxParseVideo, | ||
91 | + wxParseAudio, | ||
92 | + }, | ||
93 | + methods: { | ||
94 | + wxParseATap(e) { | ||
95 | + const { | ||
96 | + href | ||
97 | + } = e.currentTarget.dataset;// TODO currentTarget才有dataset | ||
98 | + if (!href) return; | ||
99 | + let parent = this.$parent; | ||
100 | + while(!parent.preview || typeof parent.preview !== 'function') {// TODO 遍历获取父节点执行方法 | ||
101 | + parent = parent.$parent; | ||
102 | + } | ||
103 | + parent.navigate(href, e); | ||
104 | + }, | ||
105 | + }, | ||
106 | + }; | ||
107 | +</script> |
1 | +<template> | ||
2 | + <view :class="(node.tag == 'li' ? node.classStr : (node.node==='text'?'text':''))"> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <block v-if="node.tag == 'button'"> | ||
6 | + <button type="default" size="mini"> | ||
7 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
8 | + <wx-parse-template :node="node" /> | ||
9 | + </block> | ||
10 | + </button> | ||
11 | + </block> | ||
12 | + | ||
13 | + <!--li类型--> | ||
14 | + <block v-else-if="node.tag == 'li'"> | ||
15 | + <!-- <view :class="node.classStr" :style="node.styleStr"> --> | ||
16 | + <view :style="node.styleStr"> | ||
17 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
18 | + <wx-parse-template :node="node" /> | ||
19 | + </block> | ||
20 | + </view> | ||
21 | + </block> | ||
22 | + | ||
23 | + <!--video类型--> | ||
24 | + <block v-else-if="node.tag == 'video'"> | ||
25 | + <wx-parse-video :node="node" /> | ||
26 | + </block> | ||
27 | + | ||
28 | + <!--audio类型--> | ||
29 | + <block v-else-if="node.tag == 'audio'"> | ||
30 | + <wx-parse-audio :node="node" /> | ||
31 | + </block> | ||
32 | + | ||
33 | + <!--img类型--> | ||
34 | + <block v-else-if="node.tag == 'img'"> | ||
35 | + <wx-parse-img :node="node" /> | ||
36 | + </block> | ||
37 | + | ||
38 | + <!--a类型--> | ||
39 | + <block v-else-if="node.tag == 'a'"> | ||
40 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
41 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
42 | + <wx-parse-template :node="node" /> | ||
43 | + </block> | ||
44 | + </view> | ||
45 | + </block> | ||
46 | + | ||
47 | + <!--br类型--> | ||
48 | + <block v-else-if="node.tag == 'br'"> | ||
49 | + <text>\n</text> | ||
50 | + </block> | ||
51 | + | ||
52 | + <!--其他标签--> | ||
53 | + <block v-else> | ||
54 | + <view :class="node.classStr" :style="node.styleStr"> | ||
55 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
56 | + <wx-parse-template :node="node" /> | ||
57 | + </block> | ||
58 | + </view> | ||
59 | + </block> | ||
60 | + | ||
61 | + </block> | ||
62 | + | ||
63 | + <!--判断是否是文本节点--> | ||
64 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
65 | + </view> | ||
66 | +</template> | ||
67 | + | ||
68 | +<script> | ||
69 | + import wxParseTemplate from './wxParseTemplate2'; | ||
70 | + import wxParseImg from './wxParseImg'; | ||
71 | + import wxParseVideo from './wxParseVideo'; | ||
72 | + import wxParseAudio from './wxParseAudio'; | ||
73 | + | ||
74 | + export default { | ||
75 | + name: 'wxParseTemplate1', | ||
76 | + props: { | ||
77 | + node: {}, | ||
78 | + }, | ||
79 | + components: { | ||
80 | + wxParseTemplate, | ||
81 | + wxParseImg, | ||
82 | + wxParseVideo, | ||
83 | + wxParseAudio, | ||
84 | + }, | ||
85 | + methods: { | ||
86 | + wxParseATap(e) { | ||
87 | + const { | ||
88 | + href | ||
89 | + } = e.currentTarget.dataset; | ||
90 | + if (!href) return; | ||
91 | + let parent = this.$parent; | ||
92 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
93 | + parent = parent.$parent; | ||
94 | + } | ||
95 | + parent.navigate(href, e); | ||
96 | + }, | ||
97 | + }, | ||
98 | + }; | ||
99 | +</script> |
1 | +<template> | ||
2 | + <view> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <block v-if="node.tag == 'button'"> | ||
6 | + <button type="default" size="mini"> | ||
7 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
8 | + <wx-parse-template :node="node" /> | ||
9 | + </block> | ||
10 | + </button> | ||
11 | + </block> | ||
12 | + | ||
13 | + <!--li类型--> | ||
14 | + <block v-else-if="node.tag == 'li'"> | ||
15 | + <view :class="node.classStr" :style="node.styleStr"> | ||
16 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
17 | + <wx-parse-template :node="node" /> | ||
18 | + </block> | ||
19 | + </view> | ||
20 | + </block> | ||
21 | + | ||
22 | + <!--video类型--> | ||
23 | + <block v-else-if="node.tag == 'video'"> | ||
24 | + <wx-parse-video :node="node" /> | ||
25 | + </block> | ||
26 | + | ||
27 | + <!--audio类型--> | ||
28 | + <block v-else-if="node.tag == 'audio'"> | ||
29 | + <wx-parse-audio :node="node" /> | ||
30 | + </block> | ||
31 | + | ||
32 | + <!--img类型--> | ||
33 | + <block v-else-if="node.tag == 'img'"> | ||
34 | + <wx-parse-img :node="node" /> | ||
35 | + </block> | ||
36 | + | ||
37 | + <!--a类型--> | ||
38 | + <block v-else-if="node.tag == 'a'"> | ||
39 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
40 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
41 | + <wx-parse-template :node="node" /> | ||
42 | + </block> | ||
43 | + </view> | ||
44 | + </block> | ||
45 | + | ||
46 | + <!--br类型--> | ||
47 | + <block v-else-if="node.tag == 'br'"> | ||
48 | + <text>\n</text> | ||
49 | + </block> | ||
50 | + | ||
51 | + <!--其他标签--> | ||
52 | + <block v-else> | ||
53 | + <view :class="node.classStr" :style="node.styleStr"> | ||
54 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
55 | + <wx-parse-template :node="node" /> | ||
56 | + </block> | ||
57 | + </view> | ||
58 | + </block> | ||
59 | + </block> | ||
60 | + | ||
61 | + <!--判断是否是文本节点--> | ||
62 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
63 | + </view> | ||
64 | +</template> | ||
65 | + | ||
66 | +<script> | ||
67 | + import wxParseTemplate from './wxParseTemplate11'; | ||
68 | + import wxParseImg from './wxParseImg'; | ||
69 | + import wxParseVideo from './wxParseVideo'; | ||
70 | + import wxParseAudio from './wxParseAudio'; | ||
71 | + | ||
72 | + export default { | ||
73 | + name: 'wxParseTemplate10', | ||
74 | + props: { | ||
75 | + node: {}, | ||
76 | + }, | ||
77 | + components: { | ||
78 | + wxParseTemplate, | ||
79 | + wxParseImg, | ||
80 | + wxParseVideo, | ||
81 | + wxParseAudio, | ||
82 | + }, | ||
83 | + methods: { | ||
84 | + wxParseATap(e) { | ||
85 | + const { | ||
86 | + href | ||
87 | + } = e.currentTarget.dataset; | ||
88 | + if (!href) return; | ||
89 | + let parent = this.$parent; | ||
90 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
91 | + parent = parent.$parent; | ||
92 | + } | ||
93 | + parent.navigate(href, e); | ||
94 | + }, | ||
95 | + }, | ||
96 | + }; | ||
97 | +</script> |
1 | +<template> | ||
2 | + <view> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <!--button类型--> | ||
6 | + <block v-if="node.tag == 'button'"> | ||
7 | + <button type="default" size="mini"> | ||
8 | + </button> | ||
9 | + </block> | ||
10 | + | ||
11 | + <!--li类型--> | ||
12 | + <block v-else-if="node.tag == 'li'"> | ||
13 | + <view :class="node.classStr" :style="node.styleStr"> | ||
14 | + {{node.text}} | ||
15 | + </view> | ||
16 | + </block> | ||
17 | + | ||
18 | + <!--video类型--> | ||
19 | + <block v-else-if="node.tag == 'video'"> | ||
20 | + <wx-parse-video :node="node" /> | ||
21 | + </block> | ||
22 | + | ||
23 | + <!--audio类型--> | ||
24 | + <block v-else-if="node.tag == 'audio'"> | ||
25 | + <wx-parse-audio :node="node" /> | ||
26 | + </block> | ||
27 | + | ||
28 | + <!--img类型--> | ||
29 | + <block v-else-if="node.tag == 'img'"> | ||
30 | + <wx-parse-img :node="node" /> | ||
31 | + </block> | ||
32 | + | ||
33 | + <!--a类型--> | ||
34 | + <block v-else-if="node.tag == 'a'"> | ||
35 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
36 | + {{node.text}} | ||
37 | + </view> | ||
38 | + </block> | ||
39 | + | ||
40 | + <!--br类型--> | ||
41 | + <block v-else-if="node.tag == 'br'"> | ||
42 | + <text>\n</text> | ||
43 | + </block> | ||
44 | + | ||
45 | + <!--其他标签--> | ||
46 | + <block v-else> | ||
47 | + <view :class="node.classStr" :style="node.styleStr"> | ||
48 | + {{node.text}} | ||
49 | + </view> | ||
50 | + </block> | ||
51 | + </block> | ||
52 | + | ||
53 | + <!--判断是否是文本节点--> | ||
54 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
55 | + </view> | ||
56 | +</template> | ||
57 | + | ||
58 | +<script> | ||
59 | + import wxParseImg from './wxParseImg'; | ||
60 | + import wxParseVideo from './wxParseVideo'; | ||
61 | + import wxParseAudio from './wxParseAudio'; | ||
62 | + | ||
63 | + export default { | ||
64 | + name: 'wxParseTemplate11', | ||
65 | + props: { | ||
66 | + node: {}, | ||
67 | + }, | ||
68 | + components: { | ||
69 | + wxParseImg, | ||
70 | + wxParseVideo, | ||
71 | + wxParseAudio, | ||
72 | + }, | ||
73 | + methods: { | ||
74 | + wxParseATap(e) { | ||
75 | + const { | ||
76 | + href | ||
77 | + } = e.currentTarget.dataset; | ||
78 | + if (!href) return; | ||
79 | + let parent = this.$parent; | ||
80 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
81 | + parent = parent.$parent; | ||
82 | + } | ||
83 | + parent.navigate(href, e); | ||
84 | + }, | ||
85 | + }, | ||
86 | + }; | ||
87 | +</script> |
1 | +<template> | ||
2 | + <view> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <block v-if="node.tag == 'button'"> | ||
6 | + <button type="default" size="mini"> | ||
7 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
8 | + <wx-parse-template :node="node" /> | ||
9 | + </block> | ||
10 | + </button> | ||
11 | + </block> | ||
12 | + | ||
13 | + <!--li类型--> | ||
14 | + <block v-else-if="node.tag == 'li'"> | ||
15 | + <view :class="node.classStr" :style="node.styleStr"> | ||
16 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
17 | + <wx-parse-template :node="node" /> | ||
18 | + </block> | ||
19 | + </view> | ||
20 | + </block> | ||
21 | + | ||
22 | + <!--video类型--> | ||
23 | + <block v-else-if="node.tag == 'video'"> | ||
24 | + <wx-parse-video :node="node" /> | ||
25 | + </block> | ||
26 | + | ||
27 | + <!--audio类型--> | ||
28 | + <block v-else-if="node.tag == 'audio'"> | ||
29 | + <wx-parse-audio :node="node" /> | ||
30 | + </block> | ||
31 | + | ||
32 | + <!--img类型--> | ||
33 | + <block v-else-if="node.tag == 'img'"> | ||
34 | + <wx-parse-img :node="node" /> | ||
35 | + </block> | ||
36 | + | ||
37 | + <!--a类型--> | ||
38 | + <block v-else-if="node.tag == 'a'"> | ||
39 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
40 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
41 | + <wx-parse-template :node="node" /> | ||
42 | + </block> | ||
43 | + </view> | ||
44 | + </block> | ||
45 | + | ||
46 | + <!--br类型--> | ||
47 | + <block v-else-if="node.tag == 'br'"> | ||
48 | + <text>\n</text> | ||
49 | + </block> | ||
50 | + | ||
51 | + <!--其他标签--> | ||
52 | + <block v-else> | ||
53 | + <view :class="node.classStr" :style="node.styleStr"> | ||
54 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
55 | + <wx-parse-template :node="node" /> | ||
56 | + </block> | ||
57 | + </view> | ||
58 | + </block> | ||
59 | + | ||
60 | + </block> | ||
61 | + | ||
62 | + <!--判断是否是文本节点--> | ||
63 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
64 | + </view> | ||
65 | +</template> | ||
66 | + | ||
67 | +<script> | ||
68 | + import wxParseTemplate from './wxParseTemplate3'; | ||
69 | + import wxParseImg from './wxParseImg'; | ||
70 | + import wxParseVideo from './wxParseVideo'; | ||
71 | + import wxParseAudio from './wxParseAudio'; | ||
72 | + | ||
73 | + export default { | ||
74 | + name: 'wxParseTemplate2', | ||
75 | + props: { | ||
76 | + node: {}, | ||
77 | + }, | ||
78 | + components: { | ||
79 | + wxParseTemplate, | ||
80 | + wxParseImg, | ||
81 | + wxParseVideo, | ||
82 | + wxParseAudio, | ||
83 | + }, | ||
84 | + methods: { | ||
85 | + wxParseATap(e) { | ||
86 | + const { | ||
87 | + href | ||
88 | + } = e.currentTarget.dataset; | ||
89 | + if (!href) return; | ||
90 | + let parent = this.$parent; | ||
91 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
92 | + parent = parent.$parent; | ||
93 | + } | ||
94 | + parent.navigate(href, e); | ||
95 | + }, | ||
96 | + }, | ||
97 | + }; | ||
98 | +</script> |
1 | +<template> | ||
2 | + <view> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <block v-if="node.tag == 'button'"> | ||
6 | + <button type="default" size="mini"> | ||
7 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
8 | + <wx-parse-template :node="node" /> | ||
9 | + </block> | ||
10 | + </button> | ||
11 | + </block> | ||
12 | + | ||
13 | + <!--li类型--> | ||
14 | + <block v-else-if="node.tag == 'li'"> | ||
15 | + <view :class="node.classStr" :style="node.styleStr"> | ||
16 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
17 | + <wx-parse-template :node="node" /> | ||
18 | + </block> | ||
19 | + </view> | ||
20 | + </block> | ||
21 | + | ||
22 | + <!--video类型--> | ||
23 | + <block v-else-if="node.tag == 'video'"> | ||
24 | + <wx-parse-video :node="node" /> | ||
25 | + </block> | ||
26 | + | ||
27 | + <!--audio类型--> | ||
28 | + <block v-else-if="node.tag == 'audio'"> | ||
29 | + <wx-parse-audio :node="node" /> | ||
30 | + </block> | ||
31 | + | ||
32 | + <!--img类型--> | ||
33 | + <block v-else-if="node.tag == 'img'"> | ||
34 | + <wx-parse-img :node="node" /> | ||
35 | + </block> | ||
36 | + | ||
37 | + <!--a类型--> | ||
38 | + <block v-else-if="node.tag == 'a'"> | ||
39 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
40 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
41 | + <wx-parse-template :node="node" /> | ||
42 | + </block> | ||
43 | + </view> | ||
44 | + </block> | ||
45 | + | ||
46 | + <!--br类型--> | ||
47 | + <block v-else-if="node.tag == 'br'"> | ||
48 | + <text>\n</text> | ||
49 | + </block> | ||
50 | + | ||
51 | + <!--其他标签--> | ||
52 | + <block v-else> | ||
53 | + <view :class="node.classStr" :style="node.styleStr"> | ||
54 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
55 | + <wx-parse-template :node="node" /> | ||
56 | + </block> | ||
57 | + </view> | ||
58 | + </block> | ||
59 | + | ||
60 | + </block> | ||
61 | + | ||
62 | + <!--判断是否是文本节点--> | ||
63 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
64 | + </view> | ||
65 | +</template> | ||
66 | + | ||
67 | +<script> | ||
68 | + import wxParseTemplate from './wxParseTemplate4'; | ||
69 | + import wxParseImg from './wxParseImg'; | ||
70 | + import wxParseVideo from './wxParseVideo'; | ||
71 | + import wxParseAudio from './wxParseAudio'; | ||
72 | + | ||
73 | + export default { | ||
74 | + name: 'wxParseTemplate3', | ||
75 | + props: { | ||
76 | + node: {}, | ||
77 | + }, | ||
78 | + components: { | ||
79 | + wxParseTemplate, | ||
80 | + wxParseImg, | ||
81 | + wxParseVideo, | ||
82 | + wxParseAudio, | ||
83 | + }, | ||
84 | + methods: { | ||
85 | + wxParseATap(e) { | ||
86 | + const { | ||
87 | + href | ||
88 | + } = e.currentTarget.dataset; | ||
89 | + if (!href) return; | ||
90 | + let parent = this.$parent; | ||
91 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
92 | + parent = parent.$parent; | ||
93 | + } | ||
94 | + parent.navigate(href, e); | ||
95 | + }, | ||
96 | + }, | ||
97 | + }; | ||
98 | +</script> |
1 | +<template> | ||
2 | + <view> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <block v-if="node.tag == 'button'"> | ||
6 | + <button type="default" size="mini"> | ||
7 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
8 | + <wx-parse-template :node="node" /> | ||
9 | + </block> | ||
10 | + </button> | ||
11 | + </block> | ||
12 | + | ||
13 | + <!--li类型--> | ||
14 | + <block v-else-if="node.tag == 'li'"> | ||
15 | + <view :class="node.classStr" :style="node.styleStr"> | ||
16 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
17 | + <wx-parse-template :node="node" /> | ||
18 | + </block> | ||
19 | + </view> | ||
20 | + </block> | ||
21 | + | ||
22 | + <!--video类型--> | ||
23 | + <block v-else-if="node.tag == 'video'"> | ||
24 | + <wx-parse-video :node="node" /> | ||
25 | + </block> | ||
26 | + | ||
27 | + <!--audio类型--> | ||
28 | + <block v-else-if="node.tag == 'audio'"> | ||
29 | + <wx-parse-audio :node="node" /> | ||
30 | + </block> | ||
31 | + | ||
32 | + <!--img类型--> | ||
33 | + <block v-else-if="node.tag == 'img'"> | ||
34 | + <wx-parse-img :node="node" /> | ||
35 | + </block> | ||
36 | + | ||
37 | + <!--a类型--> | ||
38 | + <block v-else-if="node.tag == 'a'"> | ||
39 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
40 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
41 | + <wx-parse-template :node="node" /> | ||
42 | + </block> | ||
43 | + </view> | ||
44 | + </block> | ||
45 | + | ||
46 | + <!--br类型--> | ||
47 | + <block v-else-if="node.tag == 'br'"> | ||
48 | + <text>\n</text> | ||
49 | + </block> | ||
50 | + | ||
51 | + <!--其他标签--> | ||
52 | + <block v-else> | ||
53 | + <view :class="node.classStr" :style="node.styleStr"> | ||
54 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
55 | + <wx-parse-template :node="node" /> | ||
56 | + </block> | ||
57 | + </view> | ||
58 | + </block> | ||
59 | + | ||
60 | + </block> | ||
61 | + | ||
62 | + <!--判断是否是文本节点--> | ||
63 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
64 | + </view> | ||
65 | +</template> | ||
66 | + | ||
67 | +<script> | ||
68 | + import wxParseTemplate from './wxParseTemplate5'; | ||
69 | + import wxParseImg from './wxParseImg'; | ||
70 | + import wxParseVideo from './wxParseVideo'; | ||
71 | + import wxParseAudio from './wxParseAudio'; | ||
72 | + | ||
73 | + export default { | ||
74 | + name: 'wxParseTemplate4', | ||
75 | + props: { | ||
76 | + node: {}, | ||
77 | + }, | ||
78 | + components: { | ||
79 | + wxParseTemplate, | ||
80 | + wxParseImg, | ||
81 | + wxParseVideo, | ||
82 | + wxParseAudio, | ||
83 | + }, | ||
84 | + methods: { | ||
85 | + wxParseATap(e) { | ||
86 | + const { | ||
87 | + href | ||
88 | + } = e.currentTarget.dataset; | ||
89 | + if (!href) return; | ||
90 | + let parent = this.$parent; | ||
91 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
92 | + parent = parent.$parent; | ||
93 | + } | ||
94 | + parent.navigate(href, e); | ||
95 | + }, | ||
96 | + }, | ||
97 | + }; | ||
98 | +</script> |
1 | +<template> | ||
2 | + <view> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <block v-if="node.tag == 'button'"> | ||
6 | + <button type="default" size="mini"> | ||
7 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
8 | + <wx-parse-template :node="node" /> | ||
9 | + </block> | ||
10 | + </button> | ||
11 | + </block> | ||
12 | + | ||
13 | + <!--li类型--> | ||
14 | + <block v-else-if="node.tag == 'li'"> | ||
15 | + <view :class="node.classStr" :style="node.styleStr"> | ||
16 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
17 | + <wx-parse-template :node="node" /> | ||
18 | + </block> | ||
19 | + </view> | ||
20 | + </block> | ||
21 | + | ||
22 | + <!--video类型--> | ||
23 | + <block v-else-if="node.tag == 'video'"> | ||
24 | + <wx-parse-video :node="node" /> | ||
25 | + </block> | ||
26 | + | ||
27 | + <!--audio类型--> | ||
28 | + <block v-else-if="node.tag == 'audio'"> | ||
29 | + <wx-parse-audio :node="node" /> | ||
30 | + </block> | ||
31 | + | ||
32 | + <!--img类型--> | ||
33 | + <block v-else-if="node.tag == 'img'"> | ||
34 | + <wx-parse-img :node="node" /> | ||
35 | + </block> | ||
36 | + | ||
37 | + <!--a类型--> | ||
38 | + <block v-else-if="node.tag == 'a'"> | ||
39 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
40 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
41 | + <wx-parse-template :node="node" /> | ||
42 | + </block> | ||
43 | + </view> | ||
44 | + </block> | ||
45 | + | ||
46 | + <!--br类型--> | ||
47 | + <block v-else-if="node.tag == 'br'"> | ||
48 | + <text>\n</text> | ||
49 | + </block> | ||
50 | + | ||
51 | + <!--其他标签--> | ||
52 | + <block v-else> | ||
53 | + <view :class="node.classStr" :style="node.styleStr"> | ||
54 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
55 | + <wx-parse-template :node="node" /> | ||
56 | + </block> | ||
57 | + </view> | ||
58 | + </block> | ||
59 | + | ||
60 | + </block> | ||
61 | + | ||
62 | + <!--判断是否是文本节点--> | ||
63 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
64 | + </view> | ||
65 | +</template> | ||
66 | + | ||
67 | +<script> | ||
68 | + import wxParseTemplate from './wxParseTemplate6'; | ||
69 | + import wxParseImg from './wxParseImg'; | ||
70 | + import wxParseVideo from './wxParseVideo'; | ||
71 | + import wxParseAudio from './wxParseAudio'; | ||
72 | + | ||
73 | + export default { | ||
74 | + name: 'wxParseTemplate5', | ||
75 | + props: { | ||
76 | + node: {}, | ||
77 | + }, | ||
78 | + components: { | ||
79 | + wxParseTemplate, | ||
80 | + wxParseImg, | ||
81 | + wxParseVideo, | ||
82 | + wxParseAudio, | ||
83 | + }, | ||
84 | + methods: { | ||
85 | + wxParseATap(e) { | ||
86 | + const { | ||
87 | + href | ||
88 | + } = e.currentTarget.dataset; | ||
89 | + if (!href) return; | ||
90 | + let parent = this.$parent; | ||
91 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
92 | + parent = parent.$parent; | ||
93 | + } | ||
94 | + parent.navigate(href, e); | ||
95 | + }, | ||
96 | + }, | ||
97 | + }; | ||
98 | +</script> |
1 | +<template> | ||
2 | + <view> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <block v-if="node.tag == 'button'"> | ||
6 | + <button type="default" size="mini"> | ||
7 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
8 | + <wx-parse-template :node="node" /> | ||
9 | + </block> | ||
10 | + </button> | ||
11 | + </block> | ||
12 | + | ||
13 | + <!--li类型--> | ||
14 | + <block v-else-if="node.tag == 'li'"> | ||
15 | + <view :class="node.classStr" :style="node.styleStr"> | ||
16 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
17 | + <wx-parse-template :node="node" /> | ||
18 | + </block> | ||
19 | + </view> | ||
20 | + </block> | ||
21 | + | ||
22 | + <!--video类型--> | ||
23 | + <block v-else-if="node.tag == 'video'"> | ||
24 | + <wx-parse-video :node="node" /> | ||
25 | + </block> | ||
26 | + | ||
27 | + <!--audio类型--> | ||
28 | + <block v-else-if="node.tag == 'audio'"> | ||
29 | + <wx-parse-audio :node="node" /> | ||
30 | + </block> | ||
31 | + | ||
32 | + <!--img类型--> | ||
33 | + <block v-else-if="node.tag == 'img'"> | ||
34 | + <wx-parse-img :node="node" /> | ||
35 | + </block> | ||
36 | + | ||
37 | + <!--a类型--> | ||
38 | + <block v-else-if="node.tag == 'a'"> | ||
39 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
40 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
41 | + <wx-parse-template :node="node" /> | ||
42 | + </block> | ||
43 | + </view> | ||
44 | + </block> | ||
45 | + | ||
46 | + <!--br类型--> | ||
47 | + <block v-else-if="node.tag == 'br'"> | ||
48 | + <text>\n</text> | ||
49 | + </block> | ||
50 | + | ||
51 | + <!--其他标签--> | ||
52 | + <block v-else> | ||
53 | + <view :class="node.classStr" :style="node.styleStr"> | ||
54 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
55 | + <wx-parse-template :node="node" /> | ||
56 | + </block> | ||
57 | + </view> | ||
58 | + </block> | ||
59 | + | ||
60 | + </block> | ||
61 | + | ||
62 | + <!--判断是否是文本节点--> | ||
63 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
64 | + </view> | ||
65 | +</template> | ||
66 | + | ||
67 | +<script> | ||
68 | + import wxParseTemplate from './wxParseTemplate7'; | ||
69 | + import wxParseImg from './wxParseImg'; | ||
70 | + import wxParseVideo from './wxParseVideo'; | ||
71 | + import wxParseAudio from './wxParseAudio'; | ||
72 | + | ||
73 | + export default { | ||
74 | + name: 'wxParseTemplate6', | ||
75 | + props: { | ||
76 | + node: {}, | ||
77 | + }, | ||
78 | + components: { | ||
79 | + wxParseTemplate, | ||
80 | + wxParseImg, | ||
81 | + wxParseVideo, | ||
82 | + wxParseAudio, | ||
83 | + }, | ||
84 | + methods: { | ||
85 | + wxParseATap(e) { | ||
86 | + const { | ||
87 | + href | ||
88 | + } = e.currentTarget.dataset; | ||
89 | + if (!href) return; | ||
90 | + let parent = this.$parent; | ||
91 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
92 | + parent = parent.$parent; | ||
93 | + } | ||
94 | + parent.navigate(href, e); | ||
95 | + }, | ||
96 | + }, | ||
97 | + }; | ||
98 | +</script> |
1 | +<template> | ||
2 | + <view> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <block v-if="node.tag == 'button'"> | ||
6 | + <button type="default" size="mini"> | ||
7 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
8 | + <wx-parse-template :node="node" /> | ||
9 | + </block> | ||
10 | + </button> | ||
11 | + </block> | ||
12 | + | ||
13 | + <!--li类型--> | ||
14 | + <block v-else-if="node.tag == 'li'"> | ||
15 | + <view :class="node.classStr" :style="node.styleStr"> | ||
16 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
17 | + <wx-parse-template :node="node" /> | ||
18 | + </block> | ||
19 | + </view> | ||
20 | + </block> | ||
21 | + | ||
22 | + <!--video类型--> | ||
23 | + <block v-else-if="node.tag == 'video'"> | ||
24 | + <wx-parse-video :node="node" /> | ||
25 | + </block> | ||
26 | + | ||
27 | + <!--audio类型--> | ||
28 | + <block v-else-if="node.tag == 'audio'"> | ||
29 | + <wx-parse-audio :node="node" /> | ||
30 | + </block> | ||
31 | + | ||
32 | + <!--img类型--> | ||
33 | + <block v-else-if="node.tag == 'img'"> | ||
34 | + <wx-parse-img :node="node" /> | ||
35 | + </block> | ||
36 | + | ||
37 | + <!--a类型--> | ||
38 | + <block v-else-if="node.tag == 'a'"> | ||
39 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
40 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
41 | + <wx-parse-template :node="node" /> | ||
42 | + </block> | ||
43 | + </view> | ||
44 | + </block> | ||
45 | + | ||
46 | + <!--br类型--> | ||
47 | + <block v-else-if="node.tag == 'br'"> | ||
48 | + <text>\n</text> | ||
49 | + </block> | ||
50 | + | ||
51 | + <!--其他标签--> | ||
52 | + <block v-else> | ||
53 | + <view :class="node.classStr" :style="node.styleStr"> | ||
54 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
55 | + <wx-parse-template :node="node" /> | ||
56 | + </block> | ||
57 | + </view> | ||
58 | + </block> | ||
59 | + | ||
60 | + </block> | ||
61 | + | ||
62 | + <!--判断是否是文本节点--> | ||
63 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
64 | + </view> | ||
65 | +</template> | ||
66 | + | ||
67 | +<script> | ||
68 | + import wxParseTemplate from './wxParseTemplate8'; | ||
69 | + import wxParseImg from './wxParseImg'; | ||
70 | + import wxParseVideo from './wxParseVideo'; | ||
71 | + import wxParseAudio from './wxParseAudio'; | ||
72 | + | ||
73 | + export default { | ||
74 | + name: 'wxParseTemplate7', | ||
75 | + props: { | ||
76 | + node: {}, | ||
77 | + }, | ||
78 | + components: { | ||
79 | + wxParseTemplate, | ||
80 | + wxParseImg, | ||
81 | + wxParseVideo, | ||
82 | + wxParseAudio, | ||
83 | + }, | ||
84 | + methods: { | ||
85 | + wxParseATap(e) { | ||
86 | + const { | ||
87 | + href | ||
88 | + } = e.currentTarget.dataset; | ||
89 | + if (!href) return; | ||
90 | + let parent = this.$parent; | ||
91 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
92 | + parent = parent.$parent; | ||
93 | + } | ||
94 | + parent.navigate(href, e); | ||
95 | + }, | ||
96 | + }, | ||
97 | + }; | ||
98 | +</script> |
1 | +<template> | ||
2 | + <view> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <block v-if="node.tag == 'button'"> | ||
6 | + <button type="default" size="mini"> | ||
7 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
8 | + <wx-parse-template :node="node" /> | ||
9 | + </block> | ||
10 | + </button> | ||
11 | + </block> | ||
12 | + | ||
13 | + <!--li类型--> | ||
14 | + <block v-else-if="node.tag == 'li'"> | ||
15 | + <view :class="node.classStr" :style="node.styleStr"> | ||
16 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
17 | + <wx-parse-template :node="node" /> | ||
18 | + </block> | ||
19 | + </view> | ||
20 | + </block> | ||
21 | + | ||
22 | + <!--video类型--> | ||
23 | + <block v-else-if="node.tag == 'video'"> | ||
24 | + <wx-parse-video :node="node" /> | ||
25 | + </block> | ||
26 | + | ||
27 | + <!--audio类型--> | ||
28 | + <block v-else-if="node.tag == 'audio'"> | ||
29 | + <wx-parse-audio :node="node" /> | ||
30 | + </block> | ||
31 | + | ||
32 | + <!--img类型--> | ||
33 | + <block v-else-if="node.tag == 'img'"> | ||
34 | + <wx-parse-img :node="node" /> | ||
35 | + </block> | ||
36 | + | ||
37 | + <!--a类型--> | ||
38 | + <block v-else-if="node.tag == 'a'"> | ||
39 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
40 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
41 | + <wx-parse-template :node="node" /> | ||
42 | + </block> | ||
43 | + </view> | ||
44 | + </block> | ||
45 | + | ||
46 | + <!--br类型--> | ||
47 | + <block v-else-if="node.tag == 'br'"> | ||
48 | + <text>\n</text> | ||
49 | + </block> | ||
50 | + | ||
51 | + <!--其他标签--> | ||
52 | + <block v-else> | ||
53 | + <view :class="node.classStr" :style="node.styleStr"> | ||
54 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
55 | + <wx-parse-template :node="node" /> | ||
56 | + </block> | ||
57 | + </view> | ||
58 | + </block> | ||
59 | + | ||
60 | + </block> | ||
61 | + | ||
62 | + <!--判断是否是文本节点--> | ||
63 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
64 | + </view> | ||
65 | +</template> | ||
66 | + | ||
67 | +<script> | ||
68 | + import wxParseTemplate from './wxParseTemplate9'; | ||
69 | + import wxParseImg from './wxParseImg'; | ||
70 | + import wxParseVideo from './wxParseVideo'; | ||
71 | + import wxParseAudio from './wxParseAudio'; | ||
72 | + | ||
73 | + export default { | ||
74 | + name: 'wxParseTemplate8', | ||
75 | + props: { | ||
76 | + node: {}, | ||
77 | + }, | ||
78 | + components: { | ||
79 | + wxParseTemplate, | ||
80 | + wxParseImg, | ||
81 | + wxParseVideo, | ||
82 | + wxParseAudio, | ||
83 | + }, | ||
84 | + methods: { | ||
85 | + wxParseATap(e) { | ||
86 | + const { | ||
87 | + href | ||
88 | + } = e.currentTarget.dataset; | ||
89 | + if (!href) return; | ||
90 | + let parent = this.$parent; | ||
91 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
92 | + parent = parent.$parent; | ||
93 | + } | ||
94 | + parent.navigate(href, e); | ||
95 | + }, | ||
96 | + }, | ||
97 | + }; | ||
98 | +</script> |
1 | +<template> | ||
2 | + <view> | ||
3 | + <!--判断是否是标签节点--> | ||
4 | + <block v-if="node.node == 'element'"> | ||
5 | + <block v-if="node.tag == 'button'"> | ||
6 | + <button type="default" size="mini"> | ||
7 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
8 | + <wx-parse-template :node="node" /> | ||
9 | + </block> | ||
10 | + </button> | ||
11 | + </block> | ||
12 | + | ||
13 | + <!--li类型--> | ||
14 | + <block v-else-if="node.tag == 'li'"> | ||
15 | + <view :class="node.classStr" :style="node.styleStr"> | ||
16 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
17 | + <wx-parse-template :node="node" /> | ||
18 | + </block> | ||
19 | + </view> | ||
20 | + </block> | ||
21 | + | ||
22 | + <!--video类型--> | ||
23 | + <block v-else-if="node.tag == 'video'"> | ||
24 | + <wx-parse-video :node="node" /> | ||
25 | + </block> | ||
26 | + | ||
27 | + <!--audio类型--> | ||
28 | + <block v-else-if="node.tag == 'audio'"> | ||
29 | + <wx-parse-audio :node="node" /> | ||
30 | + </block> | ||
31 | + | ||
32 | + <!--img类型--> | ||
33 | + <block v-else-if="node.tag == 'img'"> | ||
34 | + <wx-parse-img :node="node" /> | ||
35 | + </block> | ||
36 | + | ||
37 | + <!--a类型--> | ||
38 | + <block v-else-if="node.tag == 'a'"> | ||
39 | + <view @click="wxParseATap" :class="node.classStr" :data-href="node.attr.href" :style="node.styleStr"> | ||
40 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
41 | + <wx-parse-template :node="node" /> | ||
42 | + </block> | ||
43 | + </view> | ||
44 | + </block> | ||
45 | + | ||
46 | + <!--br类型--> | ||
47 | + <block v-else-if="node.tag == 'br'"> | ||
48 | + <text>\n</text> | ||
49 | + </block> | ||
50 | + | ||
51 | + <!--其他标签--> | ||
52 | + <block v-else> | ||
53 | + <view :class="node.classStr" :style="node.styleStr"> | ||
54 | + <block v-for="(node, index) of node.nodes" :key="index"> | ||
55 | + <wx-parse-template :node="node" /> | ||
56 | + </block> | ||
57 | + </view> | ||
58 | + </block> | ||
59 | + | ||
60 | + </block> | ||
61 | + | ||
62 | + <!--判断是否是文本节点--> | ||
63 | + <block v-else-if="node.node == 'text'">{{node.text}}</block> | ||
64 | + </view> | ||
65 | +</template> | ||
66 | + | ||
67 | +<script> | ||
68 | + import wxParseTemplate from './wxParseTemplate10'; | ||
69 | + import wxParseImg from './wxParseImg'; | ||
70 | + import wxParseVideo from './wxParseVideo'; | ||
71 | + import wxParseAudio from './wxParseAudio'; | ||
72 | + | ||
73 | + export default { | ||
74 | + name: 'wxParseTemplate9', | ||
75 | + props: { | ||
76 | + node: {}, | ||
77 | + }, | ||
78 | + components: { | ||
79 | + wxParseTemplate, | ||
80 | + wxParseImg, | ||
81 | + wxParseVideo, | ||
82 | + wxParseAudio, | ||
83 | + }, | ||
84 | + methods: { | ||
85 | + wxParseATap(e) { | ||
86 | + const { | ||
87 | + href | ||
88 | + } = e.currentTarget.dataset; | ||
89 | + if (!href) return; | ||
90 | + let parent = this.$parent; | ||
91 | + while(!parent.preview || typeof parent.preview !== 'function') { | ||
92 | + parent = parent.$parent; | ||
93 | + } | ||
94 | + parent.navigate(href, e); | ||
95 | + }, | ||
96 | + }, | ||
97 | + }; | ||
98 | +</script> |
1 | +<template> | ||
2 | + <!--增加video标签支持,并循环添加--> | ||
3 | + <view :class="node.classStr" :style="node.styleStr"> | ||
4 | + <video :class="node.classStr" class="video-video" :src="node.attr.src"></video> | ||
5 | + </view> | ||
6 | +</template> | ||
7 | + | ||
8 | +<script> | ||
9 | +export default { | ||
10 | + name: 'wxParseVideo', | ||
11 | + props: { | ||
12 | + node: {}, | ||
13 | + }, | ||
14 | +}; | ||
15 | +</script> |
components/u-parse/libs/html2json.js
0 → 100644
1 | +/** | ||
2 | + * html2Json 改造来自: https://github.com/Jxck/html2json | ||
3 | + * | ||
4 | + * | ||
5 | + * author: Di (微信小程序开发工程师) | ||
6 | + * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com) | ||
7 | + * 垂直微信小程序开发交流社区 | ||
8 | + * | ||
9 | + * github地址: https://github.com/icindy/wxParse | ||
10 | + * | ||
11 | + * for: 微信小程序富文本解析 | ||
12 | + * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184 | ||
13 | + */ | ||
14 | + | ||
15 | +import wxDiscode from './wxDiscode'; | ||
16 | +import HTMLParser from './htmlparser'; | ||
17 | + | ||
18 | +function makeMap(str) { | ||
19 | + const obj = {}; | ||
20 | + const items = str.split(','); | ||
21 | + for (let i = 0; i < items.length; i += 1) obj[items[i]] = true; | ||
22 | + return obj; | ||
23 | +} | ||
24 | + | ||
25 | +// Block Elements - HTML 5 | ||
26 | +const block = makeMap('br,code,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); | ||
27 | + | ||
28 | +// Inline Elements - HTML 5 | ||
29 | +const inline = makeMap('a,abbr,acronym,applet,b,basefont,bdo,big,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); | ||
30 | + | ||
31 | +// Elements that you can, intentionally, leave open | ||
32 | +// (and which close themselves) | ||
33 | +const closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); | ||
34 | + | ||
35 | +function removeDOCTYPE(html) { | ||
36 | + const isDocument = /<body.*>([^]*)<\/body>/.test(html); | ||
37 | + return isDocument ? RegExp.$1 : html; | ||
38 | +} | ||
39 | + | ||
40 | +function trimHtml(html) { | ||
41 | + return html | ||
42 | + .replace(/<!--.*?-->/gi, '') | ||
43 | + .replace(/\/\*.*?\*\//gi, '') | ||
44 | + .replace(/[ ]+</gi, '<') | ||
45 | + .replace(/<script[^]*<\/script>/gi, '') | ||
46 | + .replace(/<style[^]*<\/style>/gi, ''); | ||
47 | +} | ||
48 | + | ||
49 | +function getScreenInfo() { | ||
50 | + const screen = {}; | ||
51 | + wx.getSystemInfo({ | ||
52 | + success: (res) => { | ||
53 | + screen.width = res.windowWidth; | ||
54 | + screen.height = res.windowHeight; | ||
55 | + }, | ||
56 | + }); | ||
57 | + return screen; | ||
58 | +} | ||
59 | + | ||
60 | +function html2json(html, customHandler, imageProp, host) { | ||
61 | + // 处理字符串 | ||
62 | + html = removeDOCTYPE(html); | ||
63 | + html = trimHtml(html); | ||
64 | + html = wxDiscode.strDiscode(html); | ||
65 | + // 生成node节点 | ||
66 | + const bufArray = []; | ||
67 | + const results = { | ||
68 | + nodes: [], | ||
69 | + imageUrls: [], | ||
70 | + }; | ||
71 | + | ||
72 | + const screen = getScreenInfo(); | ||
73 | + function Node(tag) { | ||
74 | + this.node = 'element'; | ||
75 | + this.tag = tag; | ||
76 | + | ||
77 | + this.$screen = screen; | ||
78 | + } | ||
79 | + | ||
80 | + HTMLParser(html, { | ||
81 | + start(tag, attrs, unary) { | ||
82 | + // node for this element | ||
83 | + const node = new Node(tag); | ||
84 | + | ||
85 | + if (bufArray.length !== 0) { | ||
86 | + const parent = bufArray[0]; | ||
87 | + if (parent.nodes === undefined) { | ||
88 | + parent.nodes = []; | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
92 | + if (block[tag]) { | ||
93 | + node.tagType = 'block'; | ||
94 | + } else if (inline[tag]) { | ||
95 | + node.tagType = 'inline'; | ||
96 | + } else if (closeSelf[tag]) { | ||
97 | + node.tagType = 'closeSelf'; | ||
98 | + } | ||
99 | + | ||
100 | + node.attr = attrs.reduce((pre, attr) => { | ||
101 | + const { name } = attr; | ||
102 | + let { value } = attr; | ||
103 | + if (name === 'class') { | ||
104 | + node.classStr = value; | ||
105 | + } | ||
106 | + // has multi attibutes | ||
107 | + // make it array of attribute | ||
108 | + if (name === 'style') { | ||
109 | + node.styleStr = value; | ||
110 | + } | ||
111 | + if (value.match(/ /)) { | ||
112 | + value = value.split(' '); | ||
113 | + } | ||
114 | + | ||
115 | + // if attr already exists | ||
116 | + // merge it | ||
117 | + if (pre[name]) { | ||
118 | + if (Array.isArray(pre[name])) { | ||
119 | + // already array, push to last | ||
120 | + pre[name].push(value); | ||
121 | + } else { | ||
122 | + // single value, make it array | ||
123 | + pre[name] = [pre[name], value]; | ||
124 | + } | ||
125 | + } else { | ||
126 | + // not exist, put it | ||
127 | + pre[name] = value; | ||
128 | + } | ||
129 | + | ||
130 | + return pre; | ||
131 | + }, {}); | ||
132 | + | ||
133 | + // 优化样式相关属性 | ||
134 | + if (node.classStr) { | ||
135 | + node.classStr += ` ${node.tag}`; | ||
136 | + } else { | ||
137 | + node.classStr = node.tag; | ||
138 | + } | ||
139 | + if (node.tagType === 'inline') { | ||
140 | + node.classStr += ' inline'; | ||
141 | + } | ||
142 | + | ||
143 | + // 对img添加额外数据 | ||
144 | + if (node.tag === 'img') { | ||
145 | + let imgUrl = node.attr.src; | ||
146 | + imgUrl = wxDiscode.urlToHttpUrl(imgUrl, imageProp.domain); | ||
147 | + Object.assign(node.attr, imageProp, { | ||
148 | + src: imgUrl || '', | ||
149 | + }); | ||
150 | + if (imgUrl) { | ||
151 | + results.imageUrls.push(imgUrl); | ||
152 | + } | ||
153 | + } | ||
154 | + | ||
155 | + // 处理a标签属性 | ||
156 | + if (node.tag === 'a') { | ||
157 | + node.attr.href = node.attr.href || ''; | ||
158 | + } | ||
159 | + | ||
160 | + // 处理font标签样式属性 | ||
161 | + if (node.tag === 'font') { | ||
162 | + const fontSize = [ | ||
163 | + 'x-small', | ||
164 | + 'small', | ||
165 | + 'medium', | ||
166 | + 'large', | ||
167 | + 'x-large', | ||
168 | + 'xx-large', | ||
169 | + '-webkit-xxx-large', | ||
170 | + ]; | ||
171 | + const styleAttrs = { | ||
172 | + color: 'color', | ||
173 | + face: 'font-family', | ||
174 | + size: 'font-size', | ||
175 | + }; | ||
176 | + if (!node.styleStr) node.styleStr = ''; | ||
177 | + Object.keys(styleAttrs).forEach((key) => { | ||
178 | + if (node.attr[key]) { | ||
179 | + const value = key === 'size' ? fontSize[node.attr[key] - 1] : node.attr[key]; | ||
180 | + node.styleStr += `${styleAttrs[key]}: ${value};`; | ||
181 | + } | ||
182 | + }); | ||
183 | + } | ||
184 | + | ||
185 | + // 临时记录source资源 | ||
186 | + if (node.tag === 'source') { | ||
187 | + results.source = node.attr.src; | ||
188 | + } | ||
189 | + | ||
190 | + if (customHandler.start) { | ||
191 | + customHandler.start(node, results); | ||
192 | + } | ||
193 | + | ||
194 | + if (unary) { | ||
195 | + // if this tag doesn't have end tag | ||
196 | + // like <img src="hoge.png"/> | ||
197 | + // add to parents | ||
198 | + const parent = bufArray[0] || results; | ||
199 | + if (parent.nodes === undefined) { | ||
200 | + parent.nodes = []; | ||
201 | + } | ||
202 | + parent.nodes.push(node); | ||
203 | + } else { | ||
204 | + bufArray.unshift(node); | ||
205 | + } | ||
206 | + }, | ||
207 | + end(tag) { | ||
208 | + // merge into parent tag | ||
209 | + const node = bufArray.shift(); | ||
210 | + if (node.tag !== tag) { | ||
211 | + console.error('invalid state: mismatch end tag'); | ||
212 | + } | ||
213 | + | ||
214 | + // 当有缓存source资源时于于video补上src资源 | ||
215 | + if (node.tag === 'video' && results.source) { | ||
216 | + node.attr.src = results.source; | ||
217 | + delete results.source; | ||
218 | + } | ||
219 | + | ||
220 | + if (customHandler.end) { | ||
221 | + customHandler.end(node, results); | ||
222 | + } | ||
223 | + | ||
224 | + if (bufArray.length === 0) { | ||
225 | + results.nodes.push(node); | ||
226 | + } else { | ||
227 | + const parent = bufArray[0]; | ||
228 | + if (!parent.nodes) { | ||
229 | + parent.nodes = []; | ||
230 | + } | ||
231 | + parent.nodes.push(node); | ||
232 | + } | ||
233 | + }, | ||
234 | + chars(text) { | ||
235 | + if (!text.trim()) return; | ||
236 | + | ||
237 | + const node = { | ||
238 | + node: 'text', | ||
239 | + text, | ||
240 | + }; | ||
241 | + | ||
242 | + if (customHandler.chars) { | ||
243 | + customHandler.chars(node, results); | ||
244 | + } | ||
245 | + | ||
246 | + if (bufArray.length === 0) { | ||
247 | + results.nodes.push(node); | ||
248 | + } else { | ||
249 | + const parent = bufArray[0]; | ||
250 | + if (parent.nodes === undefined) { | ||
251 | + parent.nodes = []; | ||
252 | + } | ||
253 | + parent.nodes.push(node); | ||
254 | + } | ||
255 | + }, | ||
256 | + }); | ||
257 | + | ||
258 | + return results; | ||
259 | +} | ||
260 | + | ||
261 | +export default html2json; |
components/u-parse/libs/htmlparser.js
0 → 100644
1 | +/** | ||
2 | + * | ||
3 | + * htmlParser改造自: https://github.com/blowsie/Pure-JavaScript-HTML5-Parser | ||
4 | + * | ||
5 | + * author: Di (微信小程序开发工程师) | ||
6 | + * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com) | ||
7 | + * 垂直微信小程序开发交流社区 | ||
8 | + * | ||
9 | + * github地址: https://github.com/icindy/wxParse | ||
10 | + * | ||
11 | + * for: 微信小程序富文本解析 | ||
12 | + * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184 | ||
13 | + */ | ||
14 | +// Regular Expressions for parsing tags and attributes | ||
15 | + | ||
16 | +const startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z0-9_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/; | ||
17 | +const endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/; | ||
18 | +const attr = /([a-zA-Z0-9_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g; | ||
19 | + | ||
20 | +function makeMap(str) { | ||
21 | + const obj = {}; | ||
22 | + const items = str.split(','); | ||
23 | + for (let i = 0; i < items.length; i += 1) obj[items[i]] = true; | ||
24 | + return obj; | ||
25 | +} | ||
26 | + | ||
27 | +// Empty Elements - HTML 5 | ||
28 | +const empty = makeMap('area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr'); | ||
29 | + | ||
30 | +// Block Elements - HTML 5 | ||
31 | +const block = makeMap('address,code,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video'); | ||
32 | + | ||
33 | +// Inline Elements - HTML 5 | ||
34 | +const inline = makeMap('a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var'); | ||
35 | + | ||
36 | +// Elements that you can, intentionally, leave open | ||
37 | +// (and which close themselves) | ||
38 | +const closeSelf = makeMap('colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr'); | ||
39 | + | ||
40 | +// Attributes that have their values filled in disabled="disabled" | ||
41 | +const fillAttrs = makeMap('checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected'); | ||
42 | + | ||
43 | +function HTMLParser(html, handler) { | ||
44 | + let index; | ||
45 | + let chars; | ||
46 | + let match; | ||
47 | + let last = html; | ||
48 | + const stack = []; | ||
49 | + | ||
50 | + stack.last = () => stack[stack.length - 1]; | ||
51 | + | ||
52 | + function parseEndTag(tag, tagName) { | ||
53 | + // If no tag name is provided, clean shop | ||
54 | + let pos; | ||
55 | + if (!tagName) { | ||
56 | + pos = 0; | ||
57 | + } else { | ||
58 | + // Find the closest opened tag of the same type | ||
59 | + tagName = tagName.toLowerCase(); | ||
60 | + for (pos = stack.length - 1; pos >= 0; pos -= 1) { | ||
61 | + if (stack[pos] === tagName) break; | ||
62 | + } | ||
63 | + } | ||
64 | + if (pos >= 0) { | ||
65 | + // Close all the open elements, up the stack | ||
66 | + for (let i = stack.length - 1; i >= pos; i -= 1) { | ||
67 | + if (handler.end) handler.end(stack[i]); | ||
68 | + } | ||
69 | + | ||
70 | + // Remove the open elements from the stack | ||
71 | + stack.length = pos; | ||
72 | + } | ||
73 | + } | ||
74 | + | ||
75 | + function parseStartTag(tag, tagName, rest, unary) { | ||
76 | + tagName = tagName.toLowerCase(); | ||
77 | + | ||
78 | + if (block[tagName]) { | ||
79 | + while (stack.last() && inline[stack.last()]) { | ||
80 | + parseEndTag('', stack.last()); | ||
81 | + } | ||
82 | + } | ||
83 | + | ||
84 | + if (closeSelf[tagName] && stack.last() === tagName) { | ||
85 | + parseEndTag('', tagName); | ||
86 | + } | ||
87 | + | ||
88 | + unary = empty[tagName] || !!unary; | ||
89 | + | ||
90 | + if (!unary) stack.push(tagName); | ||
91 | + | ||
92 | + if (handler.start) { | ||
93 | + const attrs = []; | ||
94 | + | ||
95 | + rest.replace(attr, function genAttr(matches, name) { | ||
96 | + const value = arguments[2] || arguments[3] || arguments[4] || (fillAttrs[name] ? name : ''); | ||
97 | + | ||
98 | + attrs.push({ | ||
99 | + name, | ||
100 | + value, | ||
101 | + escaped: value.replace(/(^|[^\\])"/g, '$1\\"'), // " | ||
102 | + }); | ||
103 | + }); | ||
104 | + | ||
105 | + if (handler.start) { | ||
106 | + handler.start(tagName, attrs, unary); | ||
107 | + } | ||
108 | + } | ||
109 | + } | ||
110 | + | ||
111 | + while (html) { | ||
112 | + chars = true; | ||
113 | + | ||
114 | + if (html.indexOf('</') === 0) { | ||
115 | + match = html.match(endTag); | ||
116 | + | ||
117 | + if (match) { | ||
118 | + html = html.substring(match[0].length); | ||
119 | + match[0].replace(endTag, parseEndTag); | ||
120 | + chars = false; | ||
121 | + } | ||
122 | + | ||
123 | + // start tag | ||
124 | + } else if (html.indexOf('<') === 0) { | ||
125 | + match = html.match(startTag); | ||
126 | + | ||
127 | + if (match) { | ||
128 | + html = html.substring(match[0].length); | ||
129 | + match[0].replace(startTag, parseStartTag); | ||
130 | + chars = false; | ||
131 | + } | ||
132 | + } | ||
133 | + | ||
134 | + if (chars) { | ||
135 | + index = html.indexOf('<'); | ||
136 | + let text = ''; | ||
137 | + while (index === 0) { | ||
138 | + text += '<'; | ||
139 | + html = html.substring(1); | ||
140 | + index = html.indexOf('<'); | ||
141 | + } | ||
142 | + text += index < 0 ? html : html.substring(0, index); | ||
143 | + html = index < 0 ? '' : html.substring(index); | ||
144 | + | ||
145 | + if (handler.chars) handler.chars(text); | ||
146 | + } | ||
147 | + | ||
148 | + if (html === last) throw new Error(`Parse Error: ${html}`); | ||
149 | + last = html; | ||
150 | + } | ||
151 | + | ||
152 | + // Clean up any remaining tags | ||
153 | + parseEndTag(); | ||
154 | +} | ||
155 | + | ||
156 | +export default HTMLParser; |
components/u-parse/libs/wxDiscode.js
0 → 100644
1 | +// HTML 支持的数学符号 | ||
2 | +function strNumDiscode(str) { | ||
3 | + str = str.replace(/∀/g, '∀'); | ||
4 | + str = str.replace(/∂/g, '∂'); | ||
5 | + str = str.replace(/∃/g, '∃'); | ||
6 | + str = str.replace(/∅/g, '∅'); | ||
7 | + str = str.replace(/∇/g, '∇'); | ||
8 | + str = str.replace(/∈/g, '∈'); | ||
9 | + str = str.replace(/∉/g, '∉'); | ||
10 | + str = str.replace(/∋/g, '∋'); | ||
11 | + str = str.replace(/∏/g, '∏'); | ||
12 | + str = str.replace(/∑/g, '∑'); | ||
13 | + str = str.replace(/−/g, '−'); | ||
14 | + str = str.replace(/∗/g, '∗'); | ||
15 | + str = str.replace(/√/g, '√'); | ||
16 | + str = str.replace(/∝/g, '∝'); | ||
17 | + str = str.replace(/∞/g, '∞'); | ||
18 | + str = str.replace(/∠/g, '∠'); | ||
19 | + str = str.replace(/∧/g, '∧'); | ||
20 | + str = str.replace(/∨/g, '∨'); | ||
21 | + str = str.replace(/∩/g, '∩'); | ||
22 | + str = str.replace(/∪/g, '∪'); | ||
23 | + str = str.replace(/∫/g, '∫'); | ||
24 | + str = str.replace(/∴/g, '∴'); | ||
25 | + str = str.replace(/∼/g, '∼'); | ||
26 | + str = str.replace(/≅/g, '≅'); | ||
27 | + str = str.replace(/≈/g, '≈'); | ||
28 | + str = str.replace(/≠/g, '≠'); | ||
29 | + str = str.replace(/≤/g, '≤'); | ||
30 | + str = str.replace(/≥/g, '≥'); | ||
31 | + str = str.replace(/⊂/g, '⊂'); | ||
32 | + str = str.replace(/⊃/g, '⊃'); | ||
33 | + str = str.replace(/⊄/g, '⊄'); | ||
34 | + str = str.replace(/⊆/g, '⊆'); | ||
35 | + str = str.replace(/⊇/g, '⊇'); | ||
36 | + str = str.replace(/⊕/g, '⊕'); | ||
37 | + str = str.replace(/⊗/g, '⊗'); | ||
38 | + str = str.replace(/⊥/g, '⊥'); | ||
39 | + str = str.replace(/⋅/g, '⋅'); | ||
40 | + return str; | ||
41 | +} | ||
42 | + | ||
43 | +// HTML 支持的希腊字母 | ||
44 | +function strGreeceDiscode(str) { | ||
45 | + str = str.replace(/Α/g, 'Α'); | ||
46 | + str = str.replace(/Β/g, 'Β'); | ||
47 | + str = str.replace(/Γ/g, 'Γ'); | ||
48 | + str = str.replace(/Δ/g, 'Δ'); | ||
49 | + str = str.replace(/Ε/g, 'Ε'); | ||
50 | + str = str.replace(/Ζ/g, 'Ζ'); | ||
51 | + str = str.replace(/Η/g, 'Η'); | ||
52 | + str = str.replace(/Θ/g, 'Θ'); | ||
53 | + str = str.replace(/Ι/g, 'Ι'); | ||
54 | + str = str.replace(/Κ/g, 'Κ'); | ||
55 | + str = str.replace(/Λ/g, 'Λ'); | ||
56 | + str = str.replace(/Μ/g, 'Μ'); | ||
57 | + str = str.replace(/Ν/g, 'Ν'); | ||
58 | + str = str.replace(/Ξ/g, 'Ν'); | ||
59 | + str = str.replace(/Ο/g, 'Ο'); | ||
60 | + str = str.replace(/Π/g, 'Π'); | ||
61 | + str = str.replace(/Ρ/g, 'Ρ'); | ||
62 | + str = str.replace(/Σ/g, 'Σ'); | ||
63 | + str = str.replace(/Τ/g, 'Τ'); | ||
64 | + str = str.replace(/Υ/g, 'Υ'); | ||
65 | + str = str.replace(/Φ/g, 'Φ'); | ||
66 | + str = str.replace(/Χ/g, 'Χ'); | ||
67 | + str = str.replace(/Ψ/g, 'Ψ'); | ||
68 | + str = str.replace(/Ω/g, 'Ω'); | ||
69 | + | ||
70 | + str = str.replace(/α/g, 'α'); | ||
71 | + str = str.replace(/β/g, 'β'); | ||
72 | + str = str.replace(/γ/g, 'γ'); | ||
73 | + str = str.replace(/δ/g, 'δ'); | ||
74 | + str = str.replace(/ε/g, 'ε'); | ||
75 | + str = str.replace(/ζ/g, 'ζ'); | ||
76 | + str = str.replace(/η/g, 'η'); | ||
77 | + str = str.replace(/θ/g, 'θ'); | ||
78 | + str = str.replace(/ι/g, 'ι'); | ||
79 | + str = str.replace(/κ/g, 'κ'); | ||
80 | + str = str.replace(/λ/g, 'λ'); | ||
81 | + str = str.replace(/μ/g, 'μ'); | ||
82 | + str = str.replace(/ν/g, 'ν'); | ||
83 | + str = str.replace(/ξ/g, 'ξ'); | ||
84 | + str = str.replace(/ο/g, 'ο'); | ||
85 | + str = str.replace(/π/g, 'π'); | ||
86 | + str = str.replace(/ρ/g, 'ρ'); | ||
87 | + str = str.replace(/ς/g, 'ς'); | ||
88 | + str = str.replace(/σ/g, 'σ'); | ||
89 | + str = str.replace(/τ/g, 'τ'); | ||
90 | + str = str.replace(/υ/g, 'υ'); | ||
91 | + str = str.replace(/φ/g, 'φ'); | ||
92 | + str = str.replace(/χ/g, 'χ'); | ||
93 | + str = str.replace(/ψ/g, 'ψ'); | ||
94 | + str = str.replace(/ω/g, 'ω'); | ||
95 | + str = str.replace(/ϑ/g, 'ϑ'); | ||
96 | + str = str.replace(/ϒ/g, 'ϒ'); | ||
97 | + str = str.replace(/ϖ/g, 'ϖ'); | ||
98 | + str = str.replace(/·/g, '·'); | ||
99 | + return str; | ||
100 | +} | ||
101 | + | ||
102 | +function strcharacterDiscode(str) { | ||
103 | + // 加入常用解析 | ||
104 | + str = str.replace(/ /g, ' '); | ||
105 | + str = str.replace(/ /g, ' '); | ||
106 | + str = str.replace(/ /g, ' '); | ||
107 | + str = str.replace(/"/g, "'"); | ||
108 | + str = str.replace(/&/g, '&'); | ||
109 | + str = str.replace(/</g, '<'); | ||
110 | + str = str.replace(/>/g, '>'); | ||
111 | + str = str.replace(/•/g, '•'); | ||
112 | + | ||
113 | + return str; | ||
114 | +} | ||
115 | + | ||
116 | +// HTML 支持的其他实体 | ||
117 | +function strOtherDiscode(str) { | ||
118 | + str = str.replace(/Œ/g, 'Œ'); | ||
119 | + str = str.replace(/œ/g, 'œ'); | ||
120 | + str = str.replace(/Š/g, 'Š'); | ||
121 | + str = str.replace(/š/g, 'š'); | ||
122 | + str = str.replace(/Ÿ/g, 'Ÿ'); | ||
123 | + str = str.replace(/ƒ/g, 'ƒ'); | ||
124 | + str = str.replace(/ˆ/g, 'ˆ'); | ||
125 | + str = str.replace(/˜/g, '˜'); | ||
126 | + str = str.replace(/ /g, ''); | ||
127 | + str = str.replace(/ /g, ''); | ||
128 | + str = str.replace(/ /g, ''); | ||
129 | + str = str.replace(/‌/g, ''); | ||
130 | + str = str.replace(/‍/g, ''); | ||
131 | + str = str.replace(/‎/g, ''); | ||
132 | + str = str.replace(/‏/g, ''); | ||
133 | + str = str.replace(/–/g, '–'); | ||
134 | + str = str.replace(/—/g, '—'); | ||
135 | + str = str.replace(/‘/g, '‘'); | ||
136 | + str = str.replace(/’/g, '’'); | ||
137 | + str = str.replace(/‚/g, '‚'); | ||
138 | + str = str.replace(/“/g, '“'); | ||
139 | + str = str.replace(/”/g, '”'); | ||
140 | + str = str.replace(/„/g, '„'); | ||
141 | + str = str.replace(/†/g, '†'); | ||
142 | + str = str.replace(/‡/g, '‡'); | ||
143 | + str = str.replace(/•/g, '•'); | ||
144 | + str = str.replace(/…/g, '…'); | ||
145 | + str = str.replace(/‰/g, '‰'); | ||
146 | + str = str.replace(/′/g, '′'); | ||
147 | + str = str.replace(/″/g, '″'); | ||
148 | + str = str.replace(/‹/g, '‹'); | ||
149 | + str = str.replace(/›/g, '›'); | ||
150 | + str = str.replace(/‾/g, '‾'); | ||
151 | + str = str.replace(/€/g, '€'); | ||
152 | + str = str.replace(/™/g, '™'); | ||
153 | + | ||
154 | + str = str.replace(/←/g, '←'); | ||
155 | + str = str.replace(/↑/g, '↑'); | ||
156 | + str = str.replace(/→/g, '→'); | ||
157 | + str = str.replace(/↓/g, '↓'); | ||
158 | + str = str.replace(/↔/g, '↔'); | ||
159 | + str = str.replace(/↵/g, '↵'); | ||
160 | + str = str.replace(/⌈/g, '⌈'); | ||
161 | + str = str.replace(/⌉/g, '⌉'); | ||
162 | + | ||
163 | + str = str.replace(/⌊/g, '⌊'); | ||
164 | + str = str.replace(/⌋/g, '⌋'); | ||
165 | + str = str.replace(/◊/g, '◊'); | ||
166 | + str = str.replace(/♠/g, '♠'); | ||
167 | + str = str.replace(/♣/g, '♣'); | ||
168 | + str = str.replace(/♥/g, '♥'); | ||
169 | + | ||
170 | + str = str.replace(/♦/g, '♦'); | ||
171 | + str = str.replace(/'/g, "'"); | ||
172 | + return str; | ||
173 | +} | ||
174 | + | ||
175 | +function strDiscode(str) { | ||
176 | + str = strNumDiscode(str); | ||
177 | + str = strGreeceDiscode(str); | ||
178 | + str = strcharacterDiscode(str); | ||
179 | + str = strOtherDiscode(str); | ||
180 | + return str; | ||
181 | +} | ||
182 | + | ||
183 | +function urlToHttpUrl(url, domain) { | ||
184 | + if (/^\/\//.test(url)) { | ||
185 | + return `https:${url}`; | ||
186 | + } else if (/^\//.test(url)) { | ||
187 | + return `https://${domain}${url}`; | ||
188 | + } | ||
189 | + return url; | ||
190 | +} | ||
191 | + | ||
192 | +export default { | ||
193 | + strDiscode, | ||
194 | + urlToHttpUrl, | ||
195 | +}; |
components/u-parse/readme.md
0 → 100644
1 | +## uParse 适用于 uni-app/mpvue 的富文本解析组件 | ||
2 | + | ||
3 | +> 支持 Html、Markdown 解析,Fork自: [mpvue-wxParse](https://github.com/F-loat/mpvue-wxParse) | ||
4 | + | ||
5 | + | ||
6 | +## 属性 | ||
7 | + | ||
8 | +| 名称 | 类型 | 默认值 | 描述 | | ||
9 | +| -----------------|--------------- | ------------- | ---------------- | | ||
10 | +| loading | Boolean | false | 数据加载状态 | | ||
11 | +| className | String | — | 自定义 class 名称 | | ||
12 | +| content | String | — | 渲染内容 | | ||
13 | +| noData | String | 数据不能为空 | 空数据时的渲染展示 | | ||
14 | +| startHandler | Function | 见源码 | 自定义 parser 函数 | | ||
15 | +| endHandler | Function | null | 自定义 parser 函数 | | ||
16 | +| charsHandler | Function | null | 自定义 parser 函数 | | ||
17 | +| imageProp | Object | 见下文 | 图片相关参数 | | ||
18 | + | ||
19 | +### 自定义 parser 函数具体介绍 | ||
20 | + | ||
21 | +* 传入的参数为当前节点 `node` 对象及解析结果 `results` 对象,例如 `startHandler(node, results)` | ||
22 | +* 无需返回值,通过对传入的参数直接操作来完成需要的改动 | ||
23 | +* 自定义函数会在原解析函数处理之后执行 | ||
24 | + | ||
25 | +### imageProp 对象具体属性 | ||
26 | + | ||
27 | +| 名称 | 类型 | 默认值 | 描述 | | ||
28 | +| -----------------|--------------- | ------------- | ------------------ | | ||
29 | +| mode | String | 'aspectFit' | 图片裁剪、缩放的模式 | | ||
30 | +| padding | Number | 0 | 图片内边距 | | ||
31 | +| lazyLoad | Boolean | false | 图片懒加载 | | ||
32 | +| domain | String | '' | 图片服务域名 | | ||
33 | + | ||
34 | +## 事件 | ||
35 | + | ||
36 | +| 名称 | 参数 | 描述 | | ||
37 | +| -----------------|----------------- | ---------------- | | ||
38 | +| preview | 图片地址,原始事件 | 预览图片时触发 | | ||
39 | +| navigate | 链接地址,原始事件 | 点击链接时触发 | | ||
40 | + | ||
41 | +## 基本使用方法 | ||
42 | + | ||
43 | + | ||
44 | +``` vue | ||
45 | +<template> | ||
46 | + <div> | ||
47 | + <u-parse :content="article" @preview="preview" @navigate="navigate" /> | ||
48 | + </div> | ||
49 | +</template> | ||
50 | + | ||
51 | +<script> | ||
52 | +import uParse from '@/components/u-parse/u-parse.vue' | ||
53 | + | ||
54 | +export default { | ||
55 | + components: { | ||
56 | + uParse | ||
57 | + }, | ||
58 | + data () { | ||
59 | + return { | ||
60 | + article: '<div>我是HTML代码</div>' | ||
61 | + } | ||
62 | + }, | ||
63 | + methods: { | ||
64 | + preview(src, e) { | ||
65 | + // do something | ||
66 | + }, | ||
67 | + navigate(href, e) { | ||
68 | + // do something | ||
69 | + } | ||
70 | + } | ||
71 | +} | ||
72 | +</script> | ||
73 | + | ||
74 | +<style> | ||
75 | +@import url("@/components/u-parse/u-parse.css"); | ||
76 | +</style> | ||
77 | +``` | ||
78 | + | ||
79 | + | ||
80 | +## 渲染 Markdown | ||
81 | + | ||
82 | +> 先将 markdown 转换为 html 即可 | ||
83 | + | ||
84 | +``` | ||
85 | +npm install marked | ||
86 | +``` | ||
87 | + | ||
88 | +``` js | ||
89 | +import marked from 'marked' | ||
90 | +import uParse from '@/components/u-parse/u-parse.vue' | ||
91 | + | ||
92 | +export default { | ||
93 | + components: { | ||
94 | + uParse | ||
95 | + }, | ||
96 | + data () { | ||
97 | + return { | ||
98 | + article: marked(`#hello, markdown!`) | ||
99 | + } | ||
100 | + } | ||
101 | +} | ||
102 | +``` |
components/u-parse/u-parse.css
0 → 100644
1 | +/** | ||
2 | + * author: Di (微信小程序开发工程师) | ||
3 | + * organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com) | ||
4 | + * 垂直微信小程序开发交流社区 | ||
5 | + * | ||
6 | + * github地址: https://github.com/icindy/wxParse | ||
7 | + * | ||
8 | + * for: 微信小程序富文本解析 | ||
9 | + * detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184 | ||
10 | + */ | ||
11 | + | ||
12 | +.wxParse { | ||
13 | + width: 100%; | ||
14 | + font-family: Helvetica, sans-serif; | ||
15 | + font-size: 30upx; | ||
16 | + color: #666; | ||
17 | + line-height: 1.8; | ||
18 | +} | ||
19 | + | ||
20 | +.wxParse view { | ||
21 | + word-break: hyphenate; | ||
22 | +} | ||
23 | + | ||
24 | +.wxParse .inline { | ||
25 | + display: inline; | ||
26 | + margin: 0; | ||
27 | + padding: 0; | ||
28 | +} | ||
29 | + | ||
30 | +.wxParse .div { | ||
31 | + margin: 0; | ||
32 | + padding: 0; | ||
33 | +} | ||
34 | + | ||
35 | +.wxParse .h1 .text { | ||
36 | + font-size: 2em; | ||
37 | + margin: 0.67em 0; | ||
38 | +} | ||
39 | +.wxParse .h2 .text { | ||
40 | + font-size: 1.5em; | ||
41 | + margin: 0.83em 0; | ||
42 | +} | ||
43 | +.wxParse .h3 .text { | ||
44 | + font-size: 1.17em; | ||
45 | + margin: 1em 0; | ||
46 | +} | ||
47 | +.wxParse .h4 .text { | ||
48 | + margin: 1.33em 0; | ||
49 | +} | ||
50 | +.wxParse .h5 .text { | ||
51 | + font-size: 0.83em; | ||
52 | + margin: 1.67em 0; | ||
53 | +} | ||
54 | +.wxParse .h6 .text { | ||
55 | + font-size: 0.67em; | ||
56 | + margin: 2.33em 0; | ||
57 | +} | ||
58 | + | ||
59 | +.wxParse .h1 .text, | ||
60 | +.wxParse .h2 .text, | ||
61 | +.wxParse .h3 .text, | ||
62 | +.wxParse .h4 .text, | ||
63 | +.wxParse .h5 .text, | ||
64 | +.wxParse .h6 .text, | ||
65 | +.wxParse .b, | ||
66 | +.wxParse .strong { | ||
67 | + font-weight: bolder; | ||
68 | +} | ||
69 | + | ||
70 | + | ||
71 | +.wxParse .p { | ||
72 | + margin: 1em 0; | ||
73 | +} | ||
74 | + | ||
75 | +.wxParse .i, | ||
76 | +.wxParse .cite, | ||
77 | +.wxParse .em, | ||
78 | +.wxParse .var, | ||
79 | +.wxParse .address { | ||
80 | + font-style: italic; | ||
81 | +} | ||
82 | + | ||
83 | +.wxParse .pre, | ||
84 | +.wxParse .tt, | ||
85 | +.wxParse .code, | ||
86 | +.wxParse .kbd, | ||
87 | +.wxParse .samp { | ||
88 | + font-family: monospace; | ||
89 | +} | ||
90 | +.wxParse .pre { | ||
91 | + overflow: auto; | ||
92 | + background: #f5f5f5; | ||
93 | + padding: 16upx; | ||
94 | + white-space: pre; | ||
95 | + margin: 1em 0upx; | ||
96 | +} | ||
97 | +.wxParse .code { | ||
98 | + display: inline; | ||
99 | + background: #f5f5f5; | ||
100 | +} | ||
101 | + | ||
102 | +.wxParse .big { | ||
103 | + font-size: 1.17em; | ||
104 | +} | ||
105 | + | ||
106 | +.wxParse .small, | ||
107 | +.wxParse .sub, | ||
108 | +.wxParse .sup { | ||
109 | + font-size: 0.83em; | ||
110 | +} | ||
111 | + | ||
112 | +.wxParse .sub { | ||
113 | + vertical-align: sub; | ||
114 | +} | ||
115 | +.wxParse .sup { | ||
116 | + vertical-align: super; | ||
117 | +} | ||
118 | + | ||
119 | +.wxParse .s, | ||
120 | +.wxParse .strike, | ||
121 | +.wxParse .del { | ||
122 | + text-decoration: line-through; | ||
123 | +} | ||
124 | + | ||
125 | +.wxParse .strong, | ||
126 | +.wxParse .s { | ||
127 | + display: inline; | ||
128 | +} | ||
129 | + | ||
130 | +.wxParse .a { | ||
131 | + color: deepskyblue; | ||
132 | +} | ||
133 | + | ||
134 | +.wxParse .video { | ||
135 | + text-align: center; | ||
136 | + margin: 22upx 0; | ||
137 | +} | ||
138 | + | ||
139 | +.wxParse .video-video { | ||
140 | + width: 100%; | ||
141 | +} | ||
142 | + | ||
143 | +.wxParse .img { | ||
144 | + display: inline-block; | ||
145 | + width: 0; | ||
146 | + height: 0; | ||
147 | + max-width: 100%; | ||
148 | + overflow: hidden; | ||
149 | +} | ||
150 | + | ||
151 | +.wxParse .blockquote { | ||
152 | + margin: 10upx 0; | ||
153 | + padding: 22upx 0 22upx 22upx; | ||
154 | + font-family: Courier, Calibri, "宋体"; | ||
155 | + background: #f5f5f5; | ||
156 | + border-left: 6upx solid #dbdbdb; | ||
157 | +} | ||
158 | +.wxParse .blockquote .p { | ||
159 | + margin: 0; | ||
160 | +} | ||
161 | + | ||
162 | +.wxParse .ul, .wxParse .ol { | ||
163 | + display: block; | ||
164 | + margin: 1em 0; | ||
165 | + padding-left: 33upx; | ||
166 | +} | ||
167 | +.wxParse .ol { | ||
168 | + list-style-type: disc; | ||
169 | +} | ||
170 | +.wxParse .ol { | ||
171 | + list-style-type: decimal; | ||
172 | +} | ||
173 | +.wxParse .ol>weixin-parse-template,.wxParse .ul>weixin-parse-template { | ||
174 | + display: list-item; | ||
175 | + align-items: baseline; | ||
176 | + text-align: match-parent; | ||
177 | +} | ||
178 | + | ||
179 | +.wxParse .ol>.li,.wxParse .ul>.li { | ||
180 | + display: list-item; | ||
181 | + align-items: baseline; | ||
182 | + text-align: match-parent; | ||
183 | +} | ||
184 | +.wxParse .ul .ul, .wxParse .ol .ul { | ||
185 | + list-style-type: circle; | ||
186 | +} | ||
187 | +.wxParse .ol .ol .ul, .wxParse .ol .ul .ul, .wxParse .ul .ol .ul, .wxParse .ul .ul .ul { | ||
188 | + list-style-type: square; | ||
189 | +} | ||
190 | + | ||
191 | +.wxParse .u { | ||
192 | + text-decoration: underline; | ||
193 | +} | ||
194 | +.wxParse .hide { | ||
195 | + display: none; | ||
196 | +} | ||
197 | +.wxParse .del { | ||
198 | + display: inline; | ||
199 | +} | ||
200 | +.wxParse .figure { | ||
201 | + overflow: hidden; | ||
202 | +} | ||
203 | + | ||
204 | +.wxParse .table { | ||
205 | + width: 100%; | ||
206 | +} | ||
207 | +.wxParse .thead, .wxParse .tfoot, .wxParse .tr { | ||
208 | + display: flex; | ||
209 | + flex-direction: row; | ||
210 | +} | ||
211 | +.wxParse .tr { | ||
212 | + width:100%; | ||
213 | + display: flex; | ||
214 | + border-right: 2upx solid #e0e0e0; | ||
215 | + border-bottom: 2upx solid #e0e0e0; | ||
216 | +} | ||
217 | +.wxParse .th, | ||
218 | +.wxParse .td { | ||
219 | + display: flex; | ||
220 | + width: 1276upx; | ||
221 | + overflow: auto; | ||
222 | + flex: 1; | ||
223 | + padding: 11upx; | ||
224 | + border-left: 2upx solid #e0e0e0; | ||
225 | +} | ||
226 | +.wxParse .td:last { | ||
227 | + border-top: 2upx solid #e0e0e0; | ||
228 | +} | ||
229 | +.wxParse .th { | ||
230 | + background: #f0f0f0; | ||
231 | + border-top: 2upx solid #e0e0e0; | ||
232 | +} |
components/u-parse/u-parse.vue
0 → 100644
1 | +<!--** | ||
2 | + * forked from:https://github.com/F-loat/mpvue-wxParse | ||
3 | + * | ||
4 | + * github地址: https://github.com/dcloudio/uParse | ||
5 | + * | ||
6 | + * for: uni-app框架下 富文本解析 | ||
7 | + */--> | ||
8 | + | ||
9 | +<template> | ||
10 | +<!--基础元素--> | ||
11 | +<div class="wxParse" :class="className" v-if="!loading"> | ||
12 | + <block v-for="(node,index) of nodes" :key="index"> | ||
13 | + <wxParseTemplate :node="node" /> | ||
14 | + </block> | ||
15 | +</div> | ||
16 | +</template> | ||
17 | + | ||
18 | +<script> | ||
19 | +import HtmlToJson from './libs/html2json'; | ||
20 | +import wxParseTemplate from './components/wxParseTemplate0'; | ||
21 | + | ||
22 | +export default { | ||
23 | + name: 'wxParse', | ||
24 | + props: { | ||
25 | + loading: { | ||
26 | + type: Boolean, | ||
27 | + default: false, | ||
28 | + }, | ||
29 | + className: { | ||
30 | + type: String, | ||
31 | + default: '', | ||
32 | + }, | ||
33 | + content: { | ||
34 | + type: String, | ||
35 | + default: '', | ||
36 | + }, | ||
37 | + noData: { | ||
38 | + type: String, | ||
39 | + default: '<div style="color: red;">数据不能为空</div>', | ||
40 | + }, | ||
41 | + startHandler: { | ||
42 | + type: Function, | ||
43 | + default() { | ||
44 | + return (node) => { | ||
45 | + node.attr.class = null; | ||
46 | + node.attr.style = null; | ||
47 | + }; | ||
48 | + }, | ||
49 | + }, | ||
50 | + endHandler: { | ||
51 | + type: Function, | ||
52 | + default: null, | ||
53 | + }, | ||
54 | + charsHandler: { | ||
55 | + type: Function, | ||
56 | + default: null, | ||
57 | + }, | ||
58 | + imageProp: { | ||
59 | + type: Object, | ||
60 | + default() { | ||
61 | + return { | ||
62 | + mode: 'aspectFit', | ||
63 | + padding: 0, | ||
64 | + lazyLoad: false, | ||
65 | + domain: '', | ||
66 | + }; | ||
67 | + }, | ||
68 | + }, | ||
69 | + }, | ||
70 | + components: { | ||
71 | + wxParseTemplate, | ||
72 | + }, | ||
73 | + data() { | ||
74 | + return { | ||
75 | + imageUrls: [], | ||
76 | + }; | ||
77 | + }, | ||
78 | + computed: { | ||
79 | + nodes() { | ||
80 | + const { | ||
81 | + content, | ||
82 | + noData, | ||
83 | + imageProp, | ||
84 | + startHandler, | ||
85 | + endHandler, | ||
86 | + charsHandler, | ||
87 | + } = this; | ||
88 | + const parseData = content || noData; | ||
89 | + const customHandler = { | ||
90 | + start: startHandler, | ||
91 | + end: endHandler, | ||
92 | + chars: charsHandler, | ||
93 | + }; | ||
94 | + const results = HtmlToJson(parseData, customHandler, imageProp, this); | ||
95 | + this.imageUrls = results.imageUrls; | ||
96 | + console.log(results) | ||
97 | + return results.nodes; | ||
98 | + }, | ||
99 | + }, | ||
100 | + methods: { | ||
101 | + navigate(href, $event) { | ||
102 | + this.$emit('navigate', href, $event); | ||
103 | + }, | ||
104 | + preview(src, $event) { | ||
105 | + if (!this.imageUrls.length) return; | ||
106 | + wx.previewImage({ | ||
107 | + current: src, | ||
108 | + urls: this.imageUrls, | ||
109 | + }); | ||
110 | + this.$emit('preview', src, $event); | ||
111 | + }, | ||
112 | + removeImageUrl(src) { | ||
113 | + const { imageUrls } = this; | ||
114 | + imageUrls.splice(imageUrls.indexOf(src), 1); | ||
115 | + }, | ||
116 | + }, | ||
117 | +}; | ||
118 | +</script> |
@@ -207,6 +207,15 @@ | @@ -207,6 +207,15 @@ | ||
207 | } | 207 | } |
208 | 208 | ||
209 | } | 209 | } |
210 | + ,{ | ||
211 | + "path" : "pages/index/grant", | ||
212 | + "style" : | ||
213 | + { | ||
214 | + "navigationBarTitleText": "", | ||
215 | + "enablePullDownRefresh": false | ||
216 | + } | ||
217 | + | ||
218 | + } | ||
210 | ], | 219 | ], |
211 | "globalStyle": { | 220 | "globalStyle": { |
212 | "navigationBarTextStyle": "black", | 221 | "navigationBarTextStyle": "black", |
1 | <template> | 1 | <template> |
2 | <view class="buydetail"> | 2 | <view class="buydetail"> |
3 | <view class="buytop"> | 3 | <view class="buytop"> |
4 | - <text class="buytitle"> 数字货币</text> | 4 | + <!-- <text class="buytitle"> 数字货币</text> --> |
5 | <view class="buybox flexA"> | 5 | <view class="buybox flexA"> |
6 | <image :src="list1[0]" mode=""></image> | 6 | <image :src="list1[0]" mode=""></image> |
7 | <view class="buymiss"> | 7 | <view class="buymiss"> |
@@ -120,9 +120,11 @@ | @@ -120,9 +120,11 @@ | ||
120 | is_cert: "", | 120 | is_cert: "", |
121 | }, | 121 | }, |
122 | show: false, | 122 | show: false, |
123 | + opid:"", | ||
123 | } | 124 | } |
124 | }, | 125 | }, |
125 | onLoad(options) { | 126 | onLoad(options) { |
127 | + this.opid=uni.getStorageSync('openId') | ||
126 | this.product_id = options.id | 128 | this.product_id = options.id |
127 | this.product_detail() | 129 | this.product_detail() |
128 | this.last_buy_data() | 130 | this.last_buy_data() |
@@ -6,11 +6,16 @@ | @@ -6,11 +6,16 @@ | ||
6 | <view class="time"> | 6 | <view class="time"> |
7 | 发布时间{{detail.publishtime}} | 7 | 发布时间{{detail.publishtime}} |
8 | </view> | 8 | </view> |
9 | - <image src="../../static/ic_fenxiang.png" mode=""></image> | 9 | + <image src="../../static/ic_fenxiang.png" mode="" @click="shareModel=true"></image> |
10 | </view> | 10 | </view> |
11 | <rich-text :nodes="detail.content"></rich-text> | 11 | <rich-text :nodes="detail.content"></rich-text> |
12 | </view> | 12 | </view> |
13 | - | 13 | + <view class="share" v-if="shareModel" @click="shareModel=false"> |
14 | + <image src="/static/detailShare.png" mode=""></image> | ||
15 | + <view class=""> | ||
16 | + 点击这里进行分享 | ||
17 | + </view> | ||
18 | + </view> | ||
14 | </view> | 19 | </view> |
15 | </template> | 20 | </template> |
16 | 21 | ||
@@ -18,6 +23,8 @@ | @@ -18,6 +23,8 @@ | ||
18 | import { | 23 | import { |
19 | arc_detail | 24 | arc_detail |
20 | } from '@/api/index.js' | 25 | } from '@/api/index.js' |
26 | + var jweixin = require('jweixin-module'); | ||
27 | + console.log(jweixin, "000") | ||
21 | export default { | 28 | export default { |
22 | data() { | 29 | data() { |
23 | return { | 30 | return { |
@@ -26,19 +33,31 @@ | @@ -26,19 +33,31 @@ | ||
26 | title: "", | 33 | title: "", |
27 | publishtime: "", | 34 | publishtime: "", |
28 | content: "", | 35 | content: "", |
29 | - } | 36 | + }, |
37 | + shareModel: false, | ||
38 | + Images: "http://yuanjie.n.broing.cn/assets/img/share_logo.jpg", | ||
39 | + jssdk:{}, | ||
30 | } | 40 | } |
31 | }, | 41 | }, |
32 | onLoad(options) { | 42 | onLoad(options) { |
33 | this.id = options.id | 43 | this.id = options.id |
44 | + let title = uni.getStorageSync("deltitle") | ||
45 | + uni.setNavigationBarTitle({ | ||
46 | + title: title //这是修改后的导航栏文字 | ||
47 | + }) | ||
34 | this.arc_detail() | 48 | this.arc_detail() |
35 | }, | 49 | }, |
50 | + onUnload() { | ||
51 | + uni.removeStorageSync("deltitle") | ||
52 | + }, | ||
36 | methods: { | 53 | methods: { |
37 | //详情 | 54 | //详情 |
38 | async arc_detail() { | 55 | async arc_detail() { |
39 | try { | 56 | try { |
40 | - const res = await arc_detail(this.id) | 57 | + const res = await arc_detail(this.id, window.location.href) |
41 | this.detail = res.detail | 58 | this.detail = res.detail |
59 | + this.jssdk = res.jssdk | ||
60 | + this.share() | ||
42 | console.log('arc_detail', res) | 61 | console.log('arc_detail', res) |
43 | // 保存数据 | 62 | // 保存数据 |
44 | } catch (err) { | 63 | } catch (err) { |
@@ -49,6 +68,83 @@ | @@ -49,6 +68,83 @@ | ||
49 | console.log('arc_detail', err) | 68 | console.log('arc_detail', err) |
50 | } | 69 | } |
51 | }, | 70 | }, |
71 | + share() { | ||
72 | + let that = this; | ||
73 | + jweixin.config({ | ||
74 | + debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 | ||
75 | + appId: that.jssdk.appId, // 必填,公众号的唯一标识 | ||
76 | + timestamp: that.jssdk.timestamp, // 必填,生成签名的时间戳 | ||
77 | + nonceStr: that.jssdk.nonceStr, // 必填,生成签名的随机串 | ||
78 | + signature: that.jssdk.signature, // 必填,签名 | ||
79 | + jsApiList: that.jssdk.jsApiList // 必填,需要使用的JS接口列表 | ||
80 | + }) | ||
81 | + jweixin.error(function(res) { | ||
82 | + console.log(res, '错误') | ||
83 | + }); | ||
84 | + console.log('分享了', that.jssdk.signature); | ||
85 | + jweixin.ready(function() { | ||
86 | + | ||
87 | + //分享给朋友 | ||
88 | + jweixin.onMenuShareAppMessage({ | ||
89 | + title: that.detail.title, // 分享标题 | ||
90 | + link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | ||
91 | + desc: "【琉璃藏宝阁】数字藏品流转平台,顺利“琉”转,藏品“璃”手", | ||
92 | + imgUrl: that.Images, // 分享图标 | ||
93 | + success: function() { | ||
94 | + // 用户点击了分享后执行的回调函数 | ||
95 | + uni.showToast({ | ||
96 | + title: '分享成功', | ||
97 | + duration: 2000 | ||
98 | + }); | ||
99 | + }, | ||
100 | + cancel: function(res) { | ||
101 | + console.log('取消分享') | ||
102 | + } | ||
103 | + }); | ||
104 | + jweixin.updateAppMessageShareData({ | ||
105 | + title: that.detail.title, // 分享标题 | ||
106 | + link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | ||
107 | + desc: "【琉璃藏宝阁】数字藏品流转平台,顺利“琉”转,藏品“璃”手", | ||
108 | + imgUrl: that.Images, // 分享图标 | ||
109 | + success: function() { | ||
110 | + console.log('设置分享给朋友成功') | ||
111 | + }, | ||
112 | + cancel: function(res) { | ||
113 | + console.log('取消分享') | ||
114 | + } | ||
115 | + }); | ||
116 | + //分享到朋友圈 | ||
117 | + jweixin.onMenuShareTimeline({ | ||
118 | + title: that.detail.title, // 分享标题 | ||
119 | + link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | ||
120 | + desc: "【琉璃藏宝阁】数字藏品流转平台,顺利“琉”转,藏品“璃”手", | ||
121 | + imgUrl: that.Images, // 分享图标 | ||
122 | + success: function() { | ||
123 | + // 用户点击了分享后执行的回调函数 | ||
124 | + uni.showToast({ | ||
125 | + title: '分享成功', | ||
126 | + duration: 2000 | ||
127 | + }); | ||
128 | + }, | ||
129 | + cancel: function(res) { | ||
130 | + console.log('取消分享') | ||
131 | + } | ||
132 | + }); | ||
133 | + jweixin.updateTimelineShareData({ | ||
134 | + title: that.detail.title, // 分享标题 | ||
135 | + link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | ||
136 | + desc: "【琉璃藏宝阁】数字藏品流转平台,顺利“琉”转,藏品“璃”手", | ||
137 | + imgUrl: that.Images, // 分享图标 | ||
138 | + success: function() { | ||
139 | + console.log('设置分享到朋友圈成功') | ||
140 | + }, | ||
141 | + cancel: function(res) { | ||
142 | + console.log('取消分享') | ||
143 | + } | ||
144 | + }); | ||
145 | + }); | ||
146 | + }, | ||
147 | + | ||
52 | } | 148 | } |
53 | } | 149 | } |
54 | </script> | 150 | </script> |
@@ -70,4 +166,30 @@ | @@ -70,4 +166,30 @@ | ||
70 | } | 166 | } |
71 | } | 167 | } |
72 | } | 168 | } |
169 | + | ||
170 | + .share { | ||
171 | + position: fixed; | ||
172 | + left: 0; | ||
173 | + top: 0; | ||
174 | + width: 100%; | ||
175 | + height: 100%; | ||
176 | + background: rgba(0, 0, 0, .6); | ||
177 | + | ||
178 | + image { | ||
179 | + position: fixed; | ||
180 | + right: 80rpx; | ||
181 | + top: 4rpx; | ||
182 | + width: 188rpx; | ||
183 | + height: 262rpx; | ||
184 | + } | ||
185 | + | ||
186 | + view { | ||
187 | + position: fixed; | ||
188 | + right: 80rpx; | ||
189 | + top: 300rpx; | ||
190 | + color: rgba(255, 255, 255, 1); | ||
191 | + font-size: 36rpx; | ||
192 | + font-weight: 700; | ||
193 | + } | ||
194 | + } | ||
73 | </style> | 195 | </style> |
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | <view class="Detail"> | 2 | <view class="Detail"> |
3 | <view class="topbg"> | 3 | <view class="topbg"> |
4 | <view class="bgimage"> | 4 | <view class="bgimage"> |
5 | - <u-swiper :list="list1" @change="change" @click="click" :height="375"></u-swiper> | 5 | + <u-swiper :list="list1" @change="change" @click="onclick" :height="375"></u-swiper> |
6 | </view> | 6 | </view> |
7 | <view class="topmain"> | 7 | <view class="topmain"> |
8 | <view class="toptitle"> | 8 | <view class="toptitle"> |
@@ -195,13 +195,19 @@ | @@ -195,13 +195,19 @@ | ||
195 | }, | 195 | }, |
196 | onShow() { | 196 | onShow() { |
197 | 197 | ||
198 | - }, | 198 | + }, |
199 | onLoad(options) { | 199 | onLoad(options) { |
200 | this.id = options.id | 200 | this.id = options.id |
201 | this.product_detail() | 201 | this.product_detail() |
202 | - this.report_list() | 202 | + this.report_list() |
203 | }, | 203 | }, |
204 | methods: { | 204 | methods: { |
205 | + onclick(index){ | ||
206 | + uni.previewImage({ | ||
207 | + current: index, | ||
208 | + urls: this.list1, | ||
209 | + }); | ||
210 | + }, | ||
205 | goTop(){ | 211 | goTop(){ |
206 | uni.pageScrollTo({ | 212 | uni.pageScrollTo({ |
207 | scrollTop: 0 | 213 | scrollTop: 0 |
@@ -244,6 +250,7 @@ | @@ -244,6 +250,7 @@ | ||
244 | jweixin.onMenuShareAppMessage({ | 250 | jweixin.onMenuShareAppMessage({ |
245 | title: that.detail.name, // 分享标题 | 251 | title: that.detail.name, // 分享标题 |
246 | link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | 252 | link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 |
253 | + desc:"【琉璃藏宝阁】数字藏品流转平台,顺利“琉”转,藏品“璃”手", | ||
247 | imgUrl: that.detail.images_preview[0], // 分享图标 | 254 | imgUrl: that.detail.images_preview[0], // 分享图标 |
248 | success: function() { | 255 | success: function() { |
249 | // 用户点击了分享后执行的回调函数 | 256 | // 用户点击了分享后执行的回调函数 |
@@ -259,6 +266,7 @@ | @@ -259,6 +266,7 @@ | ||
259 | jweixin.updateAppMessageShareData({ | 266 | jweixin.updateAppMessageShareData({ |
260 | title: that.detail.name, // 分享标题 | 267 | title: that.detail.name, // 分享标题 |
261 | link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | 268 | link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 |
269 | + desc:"【琉璃藏宝阁】数字藏品流转平台,顺利“琉”转,藏品“璃”手", | ||
262 | imgUrl: that.detail.images_preview[0], // 分享图标 | 270 | imgUrl: that.detail.images_preview[0], // 分享图标 |
263 | success: function() { | 271 | success: function() { |
264 | console.log('设置分享给朋友成功') | 272 | console.log('设置分享给朋友成功') |
@@ -271,6 +279,7 @@ | @@ -271,6 +279,7 @@ | ||
271 | jweixin.onMenuShareTimeline({ | 279 | jweixin.onMenuShareTimeline({ |
272 | title: that.detail.name, // 分享标题 | 280 | title: that.detail.name, // 分享标题 |
273 | link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | 281 | link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 |
282 | + desc:"【琉璃藏宝阁】数字藏品流转平台,顺利“琉”转,藏品“璃”手", | ||
274 | imgUrl: that.detail.images_preview[0], // 分享图标 | 283 | imgUrl: that.detail.images_preview[0], // 分享图标 |
275 | success: function() { | 284 | success: function() { |
276 | // 用户点击了分享后执行的回调函数 | 285 | // 用户点击了分享后执行的回调函数 |
@@ -286,6 +295,7 @@ | @@ -286,6 +295,7 @@ | ||
286 | jweixin.updateTimelineShareData({ | 295 | jweixin.updateTimelineShareData({ |
287 | title: that.detail.name, // 分享标题 | 296 | title: that.detail.name, // 分享标题 |
288 | link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 | 297 | link: window.location.href, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 |
298 | + desc:"【琉璃藏宝阁】数字藏品流转平台,顺利“琉”转,藏品“璃”手", | ||
289 | imgUrl: that.detail.images_preview[0], // 分享图标 | 299 | imgUrl: that.detail.images_preview[0], // 分享图标 |
290 | success: function() { | 300 | success: function() { |
291 | console.log('设置分享到朋友圈成功') | 301 | console.log('设置分享到朋友圈成功') |
@@ -513,7 +523,9 @@ | @@ -513,7 +523,9 @@ | ||
513 | width: 168rpx; | 523 | width: 168rpx; |
514 | } | 524 | } |
515 | 525 | ||
516 | - .namelast { | 526 | + .namelast { |
527 | + width: 420rpx; | ||
528 | + word-break: break-all; | ||
517 | color: rgba(0, 0, 0, 1); | 529 | color: rgba(0, 0, 0, 1); |
518 | font-size: 28rpx; | 530 | font-size: 28rpx; |
519 | font-weight: 400; | 531 | font-weight: 400; |
pages/index/grant.vue
0 → 100644
1 | +<template> | ||
2 | + <view> | ||
3 | + <view> | ||
4 | + <!-- url为要跳转外链的地址--> | ||
5 | + <web-view :src="urls"> | ||
6 | + </web-view> | ||
7 | + </view> | ||
8 | + </view> | ||
9 | +</template> | ||
10 | + <!-- 公众号跳转 | ||
11 | + 要跳转之前的位置js | ||
12 | + gotogrant(url) { | ||
13 | + console.log(url) | ||
14 | + var url = url; | ||
15 | + uni.navigateTo({ | ||
16 | + // 此处的链接为小程序上面新建的webview页面路径,参数url为要跳转外链的地址 | ||
17 | + url: "/pages/index/grant?url=" + encodeURIComponent(url) | ||
18 | + }); | ||
19 | + }, --> | ||
20 | +<script> | ||
21 | + export default { | ||
22 | + data() { | ||
23 | + return { | ||
24 | + urls:"" | ||
25 | + } | ||
26 | + }, | ||
27 | + onLoad(val) { | ||
28 | + console.log(val) | ||
29 | + //解码 | ||
30 | + this.urls = decodeURIComponent(val.url); | ||
31 | + // 设置当前的title 如果外链中有的话将被覆盖 | ||
32 | + // if(this.isNotEmpty(val.title)){ | ||
33 | + // this.setTitle(val.title); | ||
34 | + // } | ||
35 | + }, | ||
36 | + methods: { | ||
37 | + isNotEmpty(obj) { | ||
38 | + if (typeof obj == undefined || obj == null || obj == "" || obj == "undefined" || obj.length == 0) { | ||
39 | + return false; | ||
40 | + } else { | ||
41 | + return true; | ||
42 | + } | ||
43 | + }, | ||
44 | + // 设置title | ||
45 | + setTitle(title) { | ||
46 | + uni.setNavigationBarTitle({ | ||
47 | + title: title | ||
48 | + }) | ||
49 | + }, | ||
50 | + } | ||
51 | + } | ||
52 | + //公众号跳转 | ||
53 | + // gotogrant(url) { | ||
54 | + // console.log(url) | ||
55 | + // var url = url; | ||
56 | + // uni.navigateTo({ | ||
57 | + // // 此处的链接为小程序上面新建的webview页面路径,参数url为要跳转外链的地址 | ||
58 | + // url: "/pages/index/grant?url=" + encodeURIComponent(url) | ||
59 | + // }); | ||
60 | + // } | ||
61 | +</script> | ||
62 | + | ||
63 | + | ||
64 | + | ||
65 | + | ||
66 | + |
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <view class="logo"> | 3 | <view class="logo"> |
4 | <image src="/static/ic_logo.png" mode=""></image> | 4 | <image src="/static/ic_logo.png" mode=""></image> |
5 | <view class="search" @click="gosourch"> | 5 | <view class="search" @click="gosourch"> |
6 | - <view class="tosear" > | 6 | + <view class="tosear"> |
7 | <input type="text" value="" placeholder="搜索" | 7 | <input type="text" value="" placeholder="搜索" |
8 | placeholder-style="text-align: center;font-size: 28rpx; color: rgba(194,194,194,1);" /> | 8 | placeholder-style="text-align: center;font-size: 28rpx; color: rgba(194,194,194,1);" /> |
9 | <image src="/static/icon-search.png" mode=""></image> | 9 | <image src="/static/icon-search.png" mode=""></image> |
@@ -12,14 +12,14 @@ | @@ -12,14 +12,14 @@ | ||
12 | </view> | 12 | </view> |
13 | <view class="top"> | 13 | <view class="top"> |
14 | <view class="banner"> | 14 | <view class="banner"> |
15 | - <u-swiper keyName="image_preview" :list="list1" @click="click" :indicator="true" indicatorMode="dot" | 15 | + <u-swiper keyName="image_preview" :list="list1" @click="toclick" :indicator="true" indicatorMode="dot" |
16 | radius="12" height="160" :circular="true"> | 16 | radius="12" height="160" :circular="true"> |
17 | </u-swiper> | 17 | </u-swiper> |
18 | </view> | 18 | </view> |
19 | </view> | 19 | </view> |
20 | <view class="contail"> | 20 | <view class="contail"> |
21 | <view class="nev"> | 21 | <view class="nev"> |
22 | - <view class="bar" v-for="(item,index) in categoryList" :key="index" @click="tocate(item.id)"> | 22 | + <view class="bar" v-for="(item,index) in categoryList" :key="index" @click="tocate(item.id,item.name)"> |
23 | <image class="barimg" :src="item.image_preview" mode=""></image> | 23 | <image class="barimg" :src="item.image_preview" mode=""></image> |
24 | <text>{{item.name}}</text> | 24 | <text>{{item.name}}</text> |
25 | </view> | 25 | </view> |
@@ -34,26 +34,27 @@ | @@ -34,26 +34,27 @@ | ||
34 | <view class="title"> | 34 | <view class="title"> |
35 | 相关资讯 | 35 | 相关资讯 |
36 | </view> | 36 | </view> |
37 | - <view class="more" @click="torealtime(1)"> | 37 | + <view class="more" @click="torealtime(1,'相关资讯')"> |
38 | 更多 | 38 | 更多 |
39 | <image src="/static/ic-arrow.png" mode=""></image> | 39 | <image src="/static/ic-arrow.png" mode=""></image> |
40 | </view> | 40 | </view> |
41 | </view> | 41 | </view> |
42 | <view class="newbar"> | 42 | <view class="newbar"> |
43 | - <view v-for="(item,index) in informationList" :key="index" @click="oncusdetail(item.id)">·{{item.title}}</view> | 43 | + <view v-for="(item,index) in informationList" :key="index" @click="oncusdetail(item.id,item.title)"> |
44 | + ·{{item.title}}</view> | ||
44 | </view> | 45 | </view> |
45 | </view> | 46 | </view> |
46 | - <view class="rightbox" @click="torealtime(2)"> | 47 | + <view class="rightbox" @click="torealtime(2,'热门活动')"> |
47 | <view class="righttitle"> | 48 | <view class="righttitle"> |
48 | <view class="title"> | 49 | <view class="title"> |
49 | 热门活动 | 50 | 热门活动 |
50 | </view> | 51 | </view> |
51 | - <view class="active"> | 52 | + <!-- <view class="active"> |
52 | 充值活动 | 53 | 充值活动 |
53 | - </view> | 54 | + </view> --> |
54 | </view> | 55 | </view> |
55 | <view class="activeimg"> | 56 | <view class="activeimg"> |
56 | - <image src="/static/Rectangle 2372.png" mode=""></image> | 57 | + <image src="/static/6.jpg" mode="widthFix" ></image> |
57 | <!-- <image src="/static/logo.png" mode=""></image> | 58 | <!-- <image src="/static/logo.png" mode=""></image> |
58 | <image src="/static/logo.png" mode=""></image> --> | 59 | <image src="/static/logo.png" mode=""></image> --> |
59 | </view> | 60 | </view> |
@@ -124,8 +125,8 @@ | @@ -124,8 +125,8 @@ | ||
124 | return { | 125 | return { |
125 | title: 'Hello', | 126 | title: 'Hello', |
126 | list1: [], | 127 | list1: [], |
127 | - nevlist: [1, 2, 3, 4, , 6, 7], | ||
128 | - leftlist: [1, 2, 3], | 128 | + nevlist: [], |
129 | + leftlist: [], | ||
129 | fallindex: 1, | 130 | fallindex: 1, |
130 | //瀑布 | 131 | //瀑布 |
131 | list: [], | 132 | list: [], |
@@ -139,7 +140,7 @@ | @@ -139,7 +140,7 @@ | ||
139 | onShow() { | 140 | onShow() { |
140 | this.initial() | 141 | this.initial() |
141 | }, | 142 | }, |
142 | - onLoad() { | 143 | + onLoad(e) { |
143 | this.product_list(true) | 144 | this.product_list(true) |
144 | }, | 145 | }, |
145 | onReachBottom() { | 146 | onReachBottom() { |
@@ -147,31 +148,40 @@ | @@ -147,31 +148,40 @@ | ||
147 | this.product_list() | 148 | this.product_list() |
148 | }, | 149 | }, |
149 | methods: { | 150 | methods: { |
150 | - goTop(){ | 151 | + toclick(index) { |
152 | + console.log(this.list1[index].href) | ||
153 | + uni.navigateTo({ | ||
154 | + // 此处的链接为小程序上面新建的webview页面路径,参数url为要跳转外链的地址 | ||
155 | + url: "/pages/index/grant?url=" + encodeURIComponent(this.list1[index].href) | ||
156 | + }); | ||
157 | + | ||
158 | + }, | ||
159 | + goTop() { | ||
151 | uni.pageScrollTo({ | 160 | uni.pageScrollTo({ |
152 | scrollTop: 0 | 161 | scrollTop: 0 |
153 | }); | 162 | }); |
154 | }, | 163 | }, |
155 | // 资讯详情 | 164 | // 资讯详情 |
156 | - oncusdetail(e) { | 165 | + oncusdetail(e,title) { |
166 | + uni.setStorageSync("deltitle",title) | ||
157 | uni.navigateTo({ | 167 | uni.navigateTo({ |
158 | url: "/pages/index/consultationDetails?id=" + e | 168 | url: "/pages/index/consultationDetails?id=" + e |
159 | }) | 169 | }) |
160 | }, | 170 | }, |
161 | - tocate(id) { | 171 | + tocate(id, name) { |
162 | uni.navigateTo({ | 172 | uni.navigateTo({ |
163 | - url: "/pages/index/product?sort_id="+id | 173 | + url: "/pages/index/product?sort_id=" + id + "&sort_name=" + name |
164 | }) | 174 | }) |
165 | }, | 175 | }, |
166 | - toallCate(){ | 176 | + toallCate() { |
167 | uni.navigateTo({ | 177 | uni.navigateTo({ |
168 | url: "/pages/index/category" | 178 | url: "/pages/index/category" |
169 | }) | 179 | }) |
170 | }, | 180 | }, |
171 | //咨询列表 | 181 | //咨询列表 |
172 | - torealtime(e) { | 182 | + torealtime(e,title) { |
173 | uni.navigateTo({ | 183 | uni.navigateTo({ |
174 | - url: "/pages/index/realTimeInfo?type=" + e | 184 | + url: "/pages/index/realTimeInfo?type=" + e+"&title="+title |
175 | }) | 185 | }) |
176 | }, | 186 | }, |
177 | async product_report() { | 187 | async product_report() { |
@@ -208,17 +218,17 @@ | @@ -208,17 +218,17 @@ | ||
208 | } | 218 | } |
209 | }, | 219 | }, |
210 | //产品列表 | 220 | //产品列表 |
211 | - async product_list(x,state) { | 221 | + async product_list(x, state) { |
212 | let obj = { | 222 | let obj = { |
213 | type: this.fallindex, | 223 | type: this.fallindex, |
214 | page: this.currentpage, | 224 | page: this.currentpage, |
215 | - ids: this.fallindex == 1 && state? this.idgroup.join(",") : "", | 225 | + ids: this.fallindex == 1 && state ? this.idgroup.join(",") : "", |
216 | pagenum: 15, | 226 | pagenum: 15, |
217 | } | 227 | } |
218 | try { | 228 | try { |
219 | const res = await product_list(obj) | 229 | const res = await product_list(obj) |
220 | console.log('产品列表', res) | 230 | console.log('产品列表', res) |
221 | - this.idgroup=[] | 231 | + this.idgroup = [] |
222 | this.list = x ? res.list.data : this.list.concat(res.list.data) | 232 | this.list = x ? res.list.data : this.list.concat(res.list.data) |
223 | this.list.forEach((item, index) => { | 233 | this.list.forEach((item, index) => { |
224 | item.image = item.images_preview[0] | 234 | item.image = item.images_preview[0] |
@@ -268,12 +278,12 @@ | @@ -268,12 +278,12 @@ | ||
268 | } | 278 | } |
269 | }, | 279 | }, |
270 | changefall(e) { | 280 | changefall(e) { |
271 | - let state = this.fallindex==e?1:0 | 281 | + let state = this.fallindex == e ? 1 : 0 |
272 | this.fallindex = e | 282 | this.fallindex = e |
273 | console.log(this.fallindex) | 283 | console.log(this.fallindex) |
274 | - this.currentpage=1 | ||
275 | - this.list=[] | ||
276 | - this.product_list(true,state) | 284 | + this.currentpage = 1 |
285 | + this.list = [] | ||
286 | + this.product_list(true, state) | ||
277 | }, | 287 | }, |
278 | //跳转详情 | 288 | //跳转详情 |
279 | godetail(item) { | 289 | godetail(item) { |
@@ -609,6 +619,7 @@ | @@ -609,6 +619,7 @@ | ||
609 | } | 619 | } |
610 | } | 620 | } |
611 | } | 621 | } |
622 | + | ||
612 | .goTop { | 623 | .goTop { |
613 | width: 96rpx; | 624 | width: 96rpx; |
614 | height: 96rpx; | 625 | height: 96rpx; |
@@ -48,14 +48,23 @@ | @@ -48,14 +48,23 @@ | ||
48 | keyword: "", | 48 | keyword: "", |
49 | currentpage: 1, | 49 | currentpage: 1, |
50 | sort_id: "", | 50 | sort_id: "", |
51 | + sort_name:"", | ||
51 | } | 52 | } |
52 | }, | 53 | }, |
53 | onLoad(options) { | 54 | onLoad(options) { |
54 | if (options.ktext) { | 55 | if (options.ktext) { |
55 | this.keyword = options.ktext | 56 | this.keyword = options.ktext |
57 | + uni.setNavigationBarTitle({ | ||
58 | + title: "产品" //这是修改后的导航栏文字 | ||
59 | + }) | ||
56 | } | 60 | } |
57 | if (options.sort_id) { | 61 | if (options.sort_id) { |
58 | this.sort_id = options.sort_id | 62 | this.sort_id = options.sort_id |
63 | + this.sort_name = options.sort_name | ||
64 | + let that =this | ||
65 | + uni.setNavigationBarTitle({ | ||
66 | + title: that.sort_name //这是修改后的导航栏文字 | ||
67 | + }) | ||
59 | } | 68 | } |
60 | this.product_list(true) | 69 | this.product_list(true) |
61 | }, | 70 | }, |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | <view class="banner"> | 8 | <view class="banner"> |
9 | <scroll-view scroll-x="true" style="white-space:nowrap "> | 9 | <scroll-view scroll-x="true" style="white-space:nowrap "> |
10 | <view class="nav" :class="{newnav:chooseindex==index}" v-for="(item,index) in typelist" :key="index" | 10 | <view class="nav" :class="{newnav:chooseindex==index}" v-for="(item,index) in typelist" :key="index" |
11 | - @click="choose(index,item.id)">{{item.name}} | 11 | + @click="choose(index,item.id,item.name)">{{item.name}} |
12 | <view class="tip" v-if="chooseindex==index"> | 12 | <view class="tip" v-if="chooseindex==index"> |
13 | </view> | 13 | </view> |
14 | </view> | 14 | </view> |
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | </view> | 17 | </view> |
18 | <view class="group"> | 18 | <view class="group"> |
19 | <scroll-view scroll-y="true" @scrolltolower="scrolltolower" style="height: 100vh"> | 19 | <scroll-view scroll-y="true" @scrolltolower="scrolltolower" style="height: 100vh"> |
20 | - <view class="item" v-for="(item,idx) in sortlist" :key="idx" @click="ondetail(item.id)"> | 20 | + <view class="item" v-for="(item,idx) in sortlist" :key="idx" @click="ondetail(item.id,item.title)"> |
21 | <view class="bot flexA"> | 21 | <view class="bot flexA"> |
22 | <view class="left flexA"> | 22 | <view class="left flexA"> |
23 | <image :src="item.image_preview" mode=""></image> | 23 | <image :src="item.image_preview" mode=""></image> |
@@ -47,14 +47,21 @@ | @@ -47,14 +47,21 @@ | ||
47 | keyword: "", | 47 | keyword: "", |
48 | sortlist: [], | 48 | sortlist: [], |
49 | currentpage: 1, | 49 | currentpage: 1, |
50 | + nametitle: "", | ||
50 | } | 51 | } |
51 | }, | 52 | }, |
52 | onLoad(options) { | 53 | onLoad(options) { |
53 | this.type = options.type | 54 | this.type = options.type |
55 | + let title=options.title | ||
56 | + uni.setNavigationBarTitle({ | ||
57 | + title: title //这是修改后的导航栏文字 | ||
58 | + }) | ||
54 | this.sort_list(true) | 59 | this.sort_list(true) |
60 | + | ||
55 | }, | 61 | }, |
56 | methods: { | 62 | methods: { |
57 | - ondetail(e) { | 63 | + ondetail(e,title) { |
64 | + uni.setStorageSync("deltitle",title) | ||
58 | uni.navigateTo({ | 65 | uni.navigateTo({ |
59 | url: "/pages/index/consultationDetails?id=" + e | 66 | url: "/pages/index/consultationDetails?id=" + e |
60 | }) | 67 | }) |
@@ -70,17 +77,20 @@ | @@ -70,17 +77,20 @@ | ||
70 | this.arc_list(true) | 77 | this.arc_list(true) |
71 | }, | 78 | }, |
72 | //类型选择 | 79 | //类型选择 |
73 | - choose(e, id) { | ||
74 | - this.chooseindex = e | ||
75 | - this.sortlist = [] | ||
76 | - this.sort_id = id | ||
77 | - this.arc_list(true) | 80 | + choose(e, id, name) { |
81 | + let that =this | ||
82 | + that.chooseindex = e | ||
83 | + that.sortlist = [] | ||
84 | + that.sort_id = id | ||
85 | + that.nametitle = name | ||
86 | + console.log(that.nametitle, name) | ||
87 | + that.arc_list(true) | ||
78 | }, | 88 | }, |
79 | // 分类 | 89 | // 分类 |
80 | async sort_list() { | 90 | async sort_list() { |
81 | - console.log(this.type,"000") | 91 | + console.log(this.type, "000") |
82 | let obj = { | 92 | let obj = { |
83 | - type:this.type, | 93 | + type: this.type, |
84 | keyword: this.keyword, | 94 | keyword: this.keyword, |
85 | } | 95 | } |
86 | try { | 96 | try { |
1 | <template> | 1 | <template> |
2 | <view class="top"> | 2 | <view class="top"> |
3 | - <u-search :showAction="true" actionText="搜索" :clearabled="true" v-model="ktext" @custom="onsouch(ktext)"> | 3 | + <u-search :showAction="true" actionText="搜索" :clearabled="true" v-model="ktext" @custom="onsouch(ktext)" @search="onsouch(ktext)"> |
4 | </u-search> | 4 | </u-search> |
5 | <view class="main"> | 5 | <view class="main"> |
6 | <view class="title" v-if="hostlist.length"> | 6 | <view class="title" v-if="hostlist.length"> |
1 | -<template> | ||
2 | - <view class="Send"> | ||
3 | - <view class="contail"> | ||
4 | - <view class="main"> | ||
5 | - <view class="bar"> | ||
6 | - <view class="name"> | ||
7 | - 物品名称: | ||
8 | - </view> | ||
9 | - <view class="nameinput"> | ||
10 | - <input v-model="form.name" type="text" placeholder="请输入"> | ||
11 | - </view> | ||
12 | - </view> | ||
13 | - <view class="bar"> | ||
14 | - <view class="name"> | ||
15 | - 所属分类: | ||
16 | - </view> | ||
17 | - <view class="barchoose flexA" @click="showCategory = true"> | ||
18 | - <text :style="{color:sortName=='请选择'?'grey':'#000'}">{{sortName}}</text> | ||
19 | - <image src="/static/ic-arrow2.png" mode=""></image> | ||
20 | - </view> | ||
21 | - </view> | ||
22 | - <view class="bar"> | ||
23 | - <view class="name"> | ||
24 | - 价格: | ||
25 | - </view> | ||
26 | - <view class="nameinput"> | ||
27 | - <input @input="checkNumber" v-model="form.price" type="text" placeholder="请输入(元)"> | ||
28 | - </view> | ||
29 | - </view> | ||
30 | - <view class="newbar"> | ||
31 | - <view class="name"> | ||
32 | - 物品介绍: | ||
33 | - </view> | ||
34 | - <u--textarea :autoHeight="true" maxlength="300" v-model="form.description" border="none" placeholder="请输入"></u--textarea> | ||
35 | - </view> | ||
36 | - <view class="newbar"> | ||
37 | - <view class="name"> | ||
38 | - 物品图片:(最多五张) | ||
39 | - </view> | ||
40 | - <view class="upimg"> | ||
41 | - <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple | ||
42 | - :maxCount="5"></u-upload> | ||
43 | - </view> | ||
44 | - </view> | ||
45 | - </view> | ||
46 | - | ||
47 | - <u-gap height="12" bgColor="#F6F6F6"></u-gap> | ||
48 | - <view class="main"> | ||
49 | - <view class="title"> | ||
50 | - 卖家信息 | ||
51 | - </view> | ||
52 | - <view class="bar"> | ||
53 | - <view class="name"> | ||
54 | - 姓名: | ||
55 | - </view> | ||
56 | - <view class="nameinput"> | ||
57 | - <input v-model="form.seller_name" type="text" placeholder="选填"> | ||
58 | - </view> | ||
59 | - </view> | ||
60 | - <view class="bar"> | ||
61 | - <view class="name"> | ||
62 | - 手机号: | ||
63 | - </view> | ||
64 | - <view class="nameinput"> | ||
65 | - <input v-model="form.seller_mobile" type="text" placeholder="选填"> | ||
66 | - </view> | ||
67 | - </view> | ||
68 | - | ||
69 | - <view class="bar"> | ||
70 | - <view class="name"> | ||
71 | - <text>*</text>发送账户: | ||
72 | - </view> | ||
73 | - <view class="nameinput"> | ||
74 | - <input v-model="form.package_add" type="text" placeholder="请输入手机号或钱包地址"> | ||
75 | - </view> | ||
76 | - </view> | ||
77 | - | ||
78 | - <view class="bar"> | ||
79 | - <view class="name"> | ||
80 | - <text>*</text>微信号: | ||
81 | - </view> | ||
82 | - <view class="nameinput"> | ||
83 | - <input v-model="form.wechat_num" type="text" placeholder="请输入"> | ||
84 | - </view> | ||
85 | - </view> | ||
86 | - <view class="bar"> | ||
87 | - <view class="name"> | ||
88 | - <text>*</text>保证金:{{lastInfo.cert_withdraw_price}} | ||
89 | - </view> | ||
90 | - <view class="barlast" v-if="lastInfo.is_cert_withdraw!=1"> | ||
91 | - 去缴纳<image src="/static/arrowR.png" mode=""></image> | 1 | +<template> |
2 | + <view class="Send"> | ||
3 | + <view class="contail"> | ||
4 | + <view class="main"> | ||
5 | + <view class="bar"> | ||
6 | + <view class="name"> | ||
7 | + 物品名称: | ||
92 | </view> | 8 | </view> |
93 | - <view class="barlast" v-else style="color: #18D18E;"> | ||
94 | - 已缴纳 | ||
95 | - </view> | ||
96 | - </view> | ||
97 | - <view class="bar" @click="show = true"> | ||
98 | - <view class="name"> | ||
99 | - <text>*</text>实名认证: | ||
100 | - </view> | ||
101 | - <view class="barlast" v-if="lastInfo.is_cert==0" > | ||
102 | - 去认证<image src="/static/arrowR.png" mode=""></image> | 9 | + <view class="nameinput"> |
10 | + <input v-model="form.name" type="text" placeholder="请输入"> | ||
11 | + </view> | ||
12 | + </view> | ||
13 | + <view class="bar"> | ||
14 | + <view class="name"> | ||
15 | + 所属分类: | ||
16 | + </view> | ||
17 | + <!-- @click="showCategory = true" --> | ||
18 | + <view class="barchoose flexA"> | ||
19 | + <input type="text" v-model="sortName" placeholder="搜索选择所属分类" | ||
20 | + placeholder-style="font-size: 32rpx;" @input="showbox" > | ||
21 | + <!-- <text :style="{color:sortName=='请选择'?'grey':'#000'}">{{sortName}}</text> --> | ||
22 | + <!-- <image src="/static/ic-arrow2.png" mode=""></image> --> | ||
23 | + </view> | ||
24 | + <view class="barbox" v-if="sortName&&isshowbox"> | ||
25 | + <scroll-view scroll-y="true" style="height: 100%;"> | ||
26 | + <view class="bartip" v-for="(item,index) in columns" :key="index" @click="selctCategory(item)">{{item.name}}</view> | ||
27 | + </scroll-view> | ||
28 | + </view> | ||
29 | + </view> | ||
30 | + <view class="bar"> | ||
31 | + <view class="name"> | ||
32 | + 价格: | ||
33 | + </view> | ||
34 | + <view class="nameinput"> | ||
35 | + <input @input="checkNumber" v-model="form.price" type="text" placeholder="请输入(元)"> | ||
36 | + </view> | ||
37 | + </view> | ||
38 | + <view class="newbar"> | ||
39 | + <view class="name"> | ||
40 | + 物品介绍: | ||
41 | + </view> | ||
42 | + <u--textarea :autoHeight="true" maxlength="300" v-model="form.description" border="none" | ||
43 | + placeholder="请输入"></u--textarea> | ||
44 | + </view> | ||
45 | + <view class="newbar"> | ||
46 | + <view class="name"> | ||
47 | + 物品图片:(最多五张) | ||
48 | + </view> | ||
49 | + <view class="upimg"> | ||
50 | + <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple | ||
51 | + :maxCount="5"></u-upload> | ||
52 | + </view> | ||
53 | + </view> | ||
54 | + </view> | ||
55 | + | ||
56 | + <u-gap height="12" bgColor="#F6F6F6"></u-gap> | ||
57 | + <view class="main"> | ||
58 | + <view class="title"> | ||
59 | + 卖家信息 | ||
60 | + </view> | ||
61 | + <view class="bar"> | ||
62 | + <view class="name"> | ||
63 | + 姓名: | ||
64 | + </view> | ||
65 | + <view class="nameinput"> | ||
66 | + <input v-model="form.seller_name" type="text" placeholder="选填"> | ||
67 | + </view> | ||
68 | + </view> | ||
69 | + <view class="bar"> | ||
70 | + <view class="name"> | ||
71 | + 手机号: | ||
72 | + </view> | ||
73 | + <view class="nameinput"> | ||
74 | + <input v-model="form.seller_mobile" type="text" placeholder="选填"> | ||
75 | + </view> | ||
76 | + </view> | ||
77 | + | ||
78 | + <view class="bar"> | ||
79 | + <view class="name"> | ||
80 | + <text>*</text>发送账户: | ||
81 | + </view> | ||
82 | + <view class="nameinput"> | ||
83 | + <input v-model="form.package_add" type="text" placeholder="请输入手机号或钱包地址"> | ||
84 | + </view> | ||
85 | + </view> | ||
86 | + | ||
87 | + <view class="bar"> | ||
88 | + <view class="name"> | ||
89 | + <text>*</text>微信号: | ||
90 | + </view> | ||
91 | + <view class="nameinput"> | ||
92 | + <input v-model="form.wechat_num" type="text" placeholder="请输入"> | ||
93 | + </view> | ||
94 | + </view> | ||
95 | + <view class="bar"> | ||
96 | + <view class="name"> | ||
97 | + <text>*</text>保证金:{{lastInfo.cert_withdraw_price}} | ||
98 | + </view> | ||
99 | + <view class="barlast" v-if="lastInfo.is_cert_withdraw!=1"> | ||
100 | + 去缴纳<image src="/static/arrowR.png" mode=""></image> | ||
101 | + </view> | ||
102 | + <view class="barlast" v-else style="color: #18D18E;"> | ||
103 | + 已缴纳 | ||
104 | + </view> | ||
105 | + </view> | ||
106 | + <view class="bar" @click="show = true"> | ||
107 | + <view class="name"> | ||
108 | + <text>*</text>实名认证: | ||
109 | + </view> | ||
110 | + <view class="barlast" v-if="lastInfo.is_cert==0"> | ||
111 | + 去认证<image src="/static/arrowR.png" mode=""></image> | ||
103 | </view> | 112 | </view> |
104 | <view class="barlast" v-else style="color: #18D18E;"> | 113 | <view class="barlast" v-else style="color: #18D18E;"> |
105 | 已认证 | 114 | 已认证 |
106 | - </view> | ||
107 | - </view> | 115 | + </view> |
116 | + </view> | ||
117 | + </view> | ||
118 | + <view style="height: 200rpx;"></view> | ||
119 | + <view class="btn"> | ||
120 | + <view class="paybtn" @click="send"> | ||
121 | + 提交 | ||
122 | + </view> | ||
108 | </view> | 123 | </view> |
109 | - <view style="height: 200rpx;"></view> | ||
110 | - <view class="btn"> | ||
111 | - <view class="paybtn" @click="send"> | ||
112 | - 提交 | ||
113 | - </view> | ||
114 | - </view> | ||
115 | - | ||
116 | - <u-popup :show="showmoney" :closeOnClickOverlay="false" @close="close" @open="open" mode="center" :round="12"> | ||
117 | - <view class="popname"> | ||
118 | - <view class="title"> | ||
119 | - 缴纳保证金 | ||
120 | - </view> | ||
121 | - <view class="contant"> | ||
122 | - 为了保证平台用户交易的安全性,您需要缴纳{{lastInfo.cert_withdraw_price}}元保证金后方可在平台中进行发布物品操作。交易完成后,可在余额中心中进行退回。 | ||
123 | - </view> | ||
124 | - <view class="btngroup" > | ||
125 | - <view class="concle" @click="back"> | ||
126 | - 暂不缴纳 | ||
127 | - </view> | ||
128 | - <view class="requt" @click="authorization"> | ||
129 | - 立即缴纳 | ||
130 | - </view> | ||
131 | - </view> | ||
132 | - </view> | 124 | + |
125 | + <u-popup :show="showmoney" :closeOnClickOverlay="false" @close="close" @open="open" mode="center" | ||
126 | + :round="12"> | ||
127 | + <view class="popname"> | ||
128 | + <view class="title"> | ||
129 | + 缴纳保证金 | ||
130 | + </view> | ||
131 | + <view class="contant"> | ||
132 | + 为了保证平台用户交易的安全性,您需要缴纳{{lastInfo.cert_withdraw_price}}元保证金后方可在平台中进行发布物品操作。交易完成后,可在余额中心中进行退回。 | ||
133 | + </view> | ||
134 | + <view class="btngroup"> | ||
135 | + <view class="concle" @click="back"> | ||
136 | + 暂不缴纳 | ||
137 | + </view> | ||
138 | + <view class="requt" @click="authorization"> | ||
139 | + 立即缴纳 | ||
140 | + </view> | ||
141 | + </view> | ||
142 | + </view> | ||
133 | </u-popup> | 143 | </u-popup> |
134 | <u-popup :show="show" :closeOnClickOverlay="false" @close="close" @open="open" mode="center" :round="12"> | 144 | <u-popup :show="show" :closeOnClickOverlay="false" @close="close" @open="open" mode="center" :round="12"> |
135 | <view class="popname"> | 145 | <view class="popname"> |
@@ -139,7 +149,7 @@ | @@ -139,7 +149,7 @@ | ||
139 | <view class="contant"> | 149 | <view class="contant"> |
140 | 为了保证平台用户交易的安全性,您需要实名认证后,才能在平台中进行发布物品操作 | 150 | 为了保证平台用户交易的安全性,您需要实名认证后,才能在平台中进行发布物品操作 |
141 | </view> | 151 | </view> |
142 | - <view class="btngroup" > | 152 | + <view class="btngroup"> |
143 | <view class="concle" @click="back"> | 153 | <view class="concle" @click="back"> |
144 | 暂不认证 | 154 | 暂不认证 |
145 | </view> | 155 | </view> |
@@ -148,167 +158,215 @@ | @@ -148,167 +158,215 @@ | ||
148 | </view> | 158 | </view> |
149 | </view> | 159 | </view> |
150 | </view> | 160 | </view> |
151 | - </u-popup> | 161 | + </u-popup> |
152 | </view> | 162 | </view> |
153 | - | ||
154 | - <u-picker :show="showCategory" @cancel="showCategory=false" @confirm="selctCategory" :columns="columns" keyName="name"></u-picker> | ||
155 | - <Botton :flag="3"></Botton> | ||
156 | - </view> | ||
157 | -</template> | ||
158 | - | 163 | + |
164 | + <!-- <u-picker :show="showCategory" @cancel="showCategory=false" @confirm="selctCategory" :columns="columns" | ||
165 | + keyName="name"></u-picker> --> | ||
166 | + <Botton :flag="3"></Botton> | ||
167 | + </view> | ||
168 | +</template> | ||
169 | + | ||
159 | <script> | 170 | <script> |
160 | - var that | 171 | + var that |
161 | var wx = require('jweixin-module') | 172 | var wx = require('jweixin-module') |
162 | - import {baseURL} from '@/utils/request.js' | 173 | + import { |
174 | + baseURL | ||
175 | + } from '@/utils/request.js' | ||
163 | import Botton from "@/components/Botton.vue" | 176 | import Botton from "@/components/Botton.vue" |
164 | - import {sortList,product_detail} from '@/api/index' | ||
165 | - import {toa} from '@/utils/toast.js' | ||
166 | - import { getCategory,sendProduct,getLastInfo,payGuarantee,authorization ,getOpenid,userCertWithdraw} from '@/api/send' | 177 | + import { |
178 | + sortList, | ||
179 | + product_detail, | ||
180 | + sort_search | ||
181 | + } from '@/api/index' | ||
182 | + import { | ||
183 | + toa | ||
184 | + } from '@/utils/toast.js' | ||
185 | + import { | ||
186 | + getCategory, | ||
187 | + sendProduct, | ||
188 | + getLastInfo, | ||
189 | + payGuarantee, | ||
190 | + authorization, | ||
191 | + getOpenid, | ||
192 | + userCertWithdraw | ||
193 | + } from '@/api/send' | ||
167 | export default { | 194 | export default { |
168 | - name:'send', | 195 | + name: 'send', |
169 | components: { | 196 | components: { |
170 | Botton | 197 | Botton |
171 | - }, | ||
172 | - data() { | ||
173 | - return { | ||
174 | - fileList1: [], | ||
175 | - show: false, | 198 | + }, |
199 | + data() { | ||
200 | + return { | ||
201 | + fileList1: [], | ||
202 | + show: false, | ||
176 | showmoney: false, | 203 | showmoney: false, |
177 | - showCategory:false, | ||
178 | - content:'', | 204 | + showCategory: false, |
205 | + content: '', | ||
206 | + isshowbox: true, | ||
179 | columns: [], | 207 | columns: [], |
180 | - lastInfo:{}, | ||
181 | - sortName:'请选择', | ||
182 | - form:{ | ||
183 | - product_id:'', // string 否 物品id | ||
184 | - name:'', // string 是 物品名称 | ||
185 | - sort_id:'', // integer 是 所属分类 | ||
186 | - price:'', // string 是 价格 | ||
187 | - description:'', // string 是 物品介绍 | ||
188 | - images:'', // string 是 物品图片 | ||
189 | - seller_name:'', // string 否 卖家姓名 | ||
190 | - seller_mobile:'', // string 否 手机号 | ||
191 | - package_add:'', // string 是 钱包地址 | ||
192 | - wechat_num:'', // string 是 微信号 | 208 | + lastInfo: {}, |
209 | + sortName: '', | ||
210 | + form: { | ||
211 | + product_id: '', // string 否 物品id | ||
212 | + name: '', // string 是 物品名称 | ||
213 | + sort_id: '', // integer 是 所属分类 | ||
214 | + price: '', // string 是 价格 | ||
215 | + description: '', // string 是 物品介绍 | ||
216 | + images: '', // string 是 物品图片 | ||
217 | + seller_name: '', // string 否 卖家姓名 | ||
218 | + seller_mobile: '', // string 否 手机号 | ||
219 | + package_add: '', // string 是 钱包地址 | ||
220 | + wechat_num: '', // string 是 微信号 | ||
193 | }, | 221 | }, |
194 | - code:'' | ||
195 | - } | 222 | + code: '' |
223 | + } | ||
196 | }, | 224 | }, |
197 | onLoad(e) { | 225 | onLoad(e) { |
198 | that = this | 226 | that = this |
199 | - if(e.id){ | 227 | + if (e.id) { |
200 | this.form.product_id = e.id | 228 | this.form.product_id = e.id |
201 | this.getDetail() | 229 | this.getDetail() |
202 | } | 230 | } |
203 | this.code = e.code || '' | 231 | this.code = e.code || '' |
204 | this.getLastInfo() | 232 | this.getLastInfo() |
205 | this.sortList() | 233 | this.sortList() |
206 | - if(this.code){ | 234 | + if (this.code) { |
207 | this.getOpenid() | 235 | this.getOpenid() |
208 | } | 236 | } |
209 | - | 237 | + |
210 | }, | 238 | }, |
211 | - onShow() { | ||
212 | - }, | 239 | + onShow() {}, |
213 | methods: { | 240 | methods: { |
214 | - back(){ | 241 | + //所属分类搜索 |
242 | + async showbox() { | ||
243 | + let that = this | ||
244 | + that.isshowbox = true | ||
245 | + try { | ||
246 | + const res = await sort_search(that.sortName) | ||
247 | + console.log('sort_search', res) | ||
248 | + that.columns = res.list | ||
249 | + // 保存数据 | ||
250 | + } catch (err) { | ||
251 | + uni.showToast({ | ||
252 | + title: err, | ||
253 | + icon: 'none' | ||
254 | + }) | ||
255 | + console.log('sort_search', err) | ||
256 | + } | ||
257 | + }, | ||
258 | + //所属分类确定 | ||
259 | + // showok() { | ||
260 | + // that.isshowbox = false | ||
261 | + // }, | ||
262 | + //列表选择 | ||
263 | + back() { | ||
215 | uni.navigateBack({}) | 264 | uni.navigateBack({}) |
216 | - this.showmoney=false | 265 | + this.showmoney = false |
217 | }, | 266 | }, |
218 | // 获取openid | 267 | // 获取openid |
219 | - async getOpenid(){ | ||
220 | - try { | ||
221 | - const res = await getOpenid(this.code) | ||
222 | - console.log('getOpenid', res) | ||
223 | - uni.setStorageSync('openId',res.openid) | ||
224 | - this.userCertWithdraw() | ||
225 | - // 保存数据 | ||
226 | - } catch (err) { | ||
227 | - setTimeout(()=>{ | ||
228 | - uni.showToast({ title:err,icon:'none' }) | ||
229 | - },300) | ||
230 | - uni.redirectTo({ | ||
231 | - url:'/pages/index/index' | ||
232 | - }) | ||
233 | - console.log('getOpenid', err) | ||
234 | - } | 268 | + async getOpenid() { |
269 | + try { | ||
270 | + const res = await getOpenid(this.code) | ||
271 | + console.log('getOpenid', res) | ||
272 | + uni.setStorageSync('openId', res.openid) | ||
273 | + this.userCertWithdraw() | ||
274 | + // 保存数据 | ||
275 | + } catch (err) { | ||
276 | + setTimeout(() => { | ||
277 | + uni.showToast({ | ||
278 | + title: err, | ||
279 | + icon: 'none' | ||
280 | + }) | ||
281 | + }, 300) | ||
282 | + uni.redirectTo({ | ||
283 | + url: '/pages/index/index' | ||
284 | + }) | ||
285 | + console.log('getOpenid', err) | ||
286 | + } | ||
235 | }, | 287 | }, |
236 | // 缴纳保证金 | 288 | // 缴纳保证金 |
237 | - async userCertWithdraw(){ | ||
238 | - try { | ||
239 | - const openId = uni.getStorageSync('openId') | ||
240 | - const res = await userCertWithdraw(openId) | ||
241 | - console.log(res.pay_data); | ||
242 | - console.log('userCertWithdraw', res) | ||
243 | - wx.config({ | ||
244 | - debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 | ||
245 | - appId: res.pay_data.appId, // 必填,公众号的唯一标识 | ||
246 | - timestamp: res.pay_data.timeStamp, // 必填,生成签名的时间戳 | ||
247 | - nonceStr: res.pay_data.nonceStr, // 必填,生成签名的随机串 | ||
248 | - signature: res.pay_data.paySign, // 必填,签名 | ||
249 | - jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表 | ||
250 | - }) | ||
251 | - wx.ready(function () { | ||
252 | - wx.chooseWXPay({ | ||
253 | - timestamp: res.pay_data.timeStamp, // 时间戳 | ||
254 | - nonceStr: res.pay_data.nonceStr, // 随机数 | ||
255 | - package: res.pay_data.package, // | ||
256 | - signType: res.pay_data.signType, | ||
257 | - paySign: res.pay_data.paySign, // 签名 | ||
258 | - success: function () { | ||
259 | - that.lastInfo.is_cert_withdraw = 1 | ||
260 | - that.showmoney = false | ||
261 | - that.getLastInfo() | ||
262 | - toa.success('支付成功') | ||
263 | - }, | ||
264 | - cancel: function () { | ||
265 | - setTimeout(()=>{ | ||
266 | - toa.toast('取消失败') | ||
267 | - },200) | ||
268 | - uni.navigateBack({}) | ||
269 | - }, | ||
270 | - fail: function () { | ||
271 | - setTimeout(()=>{ | ||
272 | - toa.toast('支付失败') | ||
273 | - },200) | ||
274 | - uni.navigateBack({}) | ||
275 | - } | ||
276 | - }) | ||
277 | - }) | ||
278 | - // 保存数据 | ||
279 | - } catch (err) { | ||
280 | - uni.showToast({ title:err,icon:'none' }) | ||
281 | - console.log('userCertWithdraw', err) | ||
282 | - } | 289 | + async userCertWithdraw() { |
290 | + try { | ||
291 | + const openId = uni.getStorageSync('openId') | ||
292 | + const res = await userCertWithdraw(openId) | ||
293 | + console.log(res.pay_data); | ||
294 | + console.log('userCertWithdraw', res) | ||
295 | + wx.config({ | ||
296 | + debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 | ||
297 | + appId: res.pay_data.appId, // 必填,公众号的唯一标识 | ||
298 | + timestamp: res.pay_data.timeStamp, // 必填,生成签名的时间戳 | ||
299 | + nonceStr: res.pay_data.nonceStr, // 必填,生成签名的随机串 | ||
300 | + signature: res.pay_data.paySign, // 必填,签名 | ||
301 | + jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表 | ||
302 | + }) | ||
303 | + wx.ready(function() { | ||
304 | + wx.chooseWXPay({ | ||
305 | + timestamp: res.pay_data.timeStamp, // 时间戳 | ||
306 | + nonceStr: res.pay_data.nonceStr, // 随机数 | ||
307 | + package: res.pay_data.package, // | ||
308 | + signType: res.pay_data.signType, | ||
309 | + paySign: res.pay_data.paySign, // 签名 | ||
310 | + success: function() { | ||
311 | + that.lastInfo.is_cert_withdraw = 1 | ||
312 | + that.showmoney = false | ||
313 | + that.getLastInfo() | ||
314 | + toa.success('支付成功') | ||
315 | + }, | ||
316 | + cancel: function() { | ||
317 | + setTimeout(() => { | ||
318 | + toa.toast('取消失败') | ||
319 | + }, 200) | ||
320 | + uni.navigateBack({}) | ||
321 | + }, | ||
322 | + fail: function() { | ||
323 | + setTimeout(() => { | ||
324 | + toa.toast('支付失败') | ||
325 | + }, 200) | ||
326 | + uni.navigateBack({}) | ||
327 | + } | ||
328 | + }) | ||
329 | + }) | ||
330 | + // 保存数据 | ||
331 | + } catch (err) { | ||
332 | + uni.showToast({ | ||
333 | + title: err, | ||
334 | + icon: 'none' | ||
335 | + }) | ||
336 | + console.log('userCertWithdraw', err) | ||
337 | + } | ||
283 | }, | 338 | }, |
284 | // 获取详情 | 339 | // 获取详情 |
285 | - async getDetail(){ | ||
286 | - try { | ||
287 | - const res = await product_detail(this.form.product_id) | ||
288 | - // this.form = res.detail | ||
289 | - this.form.sort_id = res.detail.sort.id | ||
290 | - this.sortName = res.detail.sort.name | ||
291 | - this.form.product_id = res.detail.id | ||
292 | - this.form.name = res.detail.name | ||
293 | - this.form.price = res.detail.price | ||
294 | - this.form.description = res.detail.description | ||
295 | - res.detail.fileList.forEach(it=>{ | ||
296 | - it.shortUrl = it.url | ||
297 | - it.url = it.fullUrl | ||
298 | - }) | ||
299 | - this.fileList1 = res.detail.fileList | ||
300 | - console.log(this.fileList1,'图片'); | ||
301 | - console.log('getDetail', res) | ||
302 | - // 保存数据 | ||
303 | - } catch (err) { | ||
304 | - uni.showToast({ title:err,icon:'none' }) | ||
305 | - console.log('getDetail', err) | ||
306 | - } | 340 | + async getDetail() { |
341 | + try { | ||
342 | + const res = await product_detail(this.form.product_id) | ||
343 | + // this.form = res.detail | ||
344 | + this.form.sort_id = res.detail.sort.id | ||
345 | + this.sortName = res.detail.sort.name | ||
346 | + this.form.product_id = res.detail.id | ||
347 | + this.form.name = res.detail.name | ||
348 | + this.form.price = res.detail.price | ||
349 | + this.form.description = res.detail.description | ||
350 | + res.detail.fileList.forEach(it => { | ||
351 | + it.shortUrl = it.url | ||
352 | + it.url = it.fullUrl | ||
353 | + }) | ||
354 | + this.fileList1 = res.detail.fileList | ||
355 | + console.log(this.fileList1, '图片'); | ||
356 | + console.log('getDetail', res) | ||
357 | + // 保存数据 | ||
358 | + } catch (err) { | ||
359 | + uni.showToast({ | ||
360 | + title: err, | ||
361 | + icon: 'none' | ||
362 | + }) | ||
363 | + console.log('getDetail', err) | ||
364 | + } | ||
307 | }, | 365 | }, |
308 | checkNumber(e) { | 366 | checkNumber(e) { |
309 | let val = e.target.value.replace(/(^\s*)|(\s*$)/g, "") | 367 | let val = e.target.value.replace(/(^\s*)|(\s*$)/g, "") |
310 | var reg = /[^\d.]/g | 368 | var reg = /[^\d.]/g |
311 | - | 369 | + |
312 | // 只能是数字和小数点,不能是其他输入 | 370 | // 只能是数字和小数点,不能是其他输入 |
313 | val = val.replace(reg, "") | 371 | val = val.replace(reg, "") |
314 | // // 保证第一位只能是数字,不能是点 | 372 | // // 保证第一位只能是数字,不能是点 |
@@ -322,347 +380,395 @@ | @@ -322,347 +380,395 @@ | ||
322 | this.form.price = val; | 380 | this.form.price = val; |
323 | }) | 381 | }) |
324 | }, | 382 | }, |
325 | - async sortList(){ | ||
326 | - try { | ||
327 | - const res = await sortList(2) | ||
328 | - this.columns = [res.list] | ||
329 | - console.log('sortList', res) | ||
330 | - // 保存数据 | ||
331 | - } catch (err) { | ||
332 | - uni.showToast({ title:err,icon:'none' }) | ||
333 | - console.log('sortList', err) | ||
334 | - } | 383 | + async sortList() { |
384 | + try { | ||
385 | + const res = await sortList(2) | ||
386 | + this.columns = res.list | ||
387 | + console.log('sortList', this.columns, "0") | ||
388 | + // 保存数据 | ||
389 | + } catch (err) { | ||
390 | + uni.showToast({ | ||
391 | + title: err, | ||
392 | + icon: 'none' | ||
393 | + }) | ||
394 | + console.log('sortList', err) | ||
395 | + } | ||
396 | + }, | ||
397 | + async getLastInfo() { | ||
398 | + try { | ||
399 | + const res = await getLastInfo() | ||
400 | + this.lastInfo = res.detail | ||
401 | + console.log(1); | ||
402 | + if (res.detail.is_cert == 0) { | ||
403 | + return this.show = true | ||
404 | + } | ||
405 | + if (res.detail.is_cert_withdraw != 1 && !this.code) { | ||
406 | + this.showmoney = true | ||
407 | + } | ||
408 | + console.log(2); | ||
409 | + console.log(res.detail.is_cert_withdraw != 1, !this.code); | ||
410 | + this.form.seller_mobile = res.detail.seller_mobile | ||
411 | + this.form.seller_name = res.detail.seller_name | ||
412 | + this.form.package_add = res.detail.package_add | ||
413 | + this.form.wechat_num = res.detail.wechat_num | ||
414 | + console.log('getLastInfo', res) | ||
415 | + // 保存数据 | ||
416 | + } catch (err) { | ||
417 | + uni.showToast({ | ||
418 | + title: err, | ||
419 | + icon: 'none' | ||
420 | + }) | ||
421 | + console.log('getLastInfo', err) | ||
422 | + } | ||
423 | + }, | ||
424 | + open() { | ||
425 | + // console.log('open'); | ||
426 | + }, | ||
427 | + close() { | ||
428 | + this.show = false | ||
429 | + this.showmoney = false | ||
430 | + // console.log('close'); | ||
335 | }, | 431 | }, |
336 | - async getLastInfo(){ | ||
337 | - try { | ||
338 | - const res = await getLastInfo() | ||
339 | - this.lastInfo = res.detail | ||
340 | - console.log(1); | ||
341 | - if(res.detail.is_cert==0){ return this.show = true} | ||
342 | - if(res.detail.is_cert_withdraw!=1 && !this.code){ this.showmoney = true} | ||
343 | - console.log(2); | ||
344 | - console.log(res.detail.is_cert_withdraw!=1,!this.code); | ||
345 | - this.form.seller_mobile = res.detail.seller_mobile | ||
346 | - this.form.seller_name = res.detail.seller_name | ||
347 | - this.form.package_add = res.detail.package_add | ||
348 | - this.form.wechat_num = res.detail.wechat_num | ||
349 | - console.log('getLastInfo', res) | ||
350 | - // 保存数据 | ||
351 | - } catch (err) { | ||
352 | - uni.showToast({ title:err,icon:'none' }) | ||
353 | - console.log('getLastInfo', err) | ||
354 | - } | ||
355 | - }, | ||
356 | - open() { | ||
357 | - // console.log('open'); | ||
358 | - }, | ||
359 | - close() { | ||
360 | - this.show = false | ||
361 | - this.showmoney = false | ||
362 | - // console.log('close'); | ||
363 | - }, | ||
364 | - // 删除图片 | ||
365 | - deletePic(event) { | ||
366 | - this[`fileList${event.name}`].splice(event.index, 1) | ||
367 | - }, | ||
368 | - // 新增图片 | ||
369 | - async afterRead(event) { | ||
370 | - // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 | ||
371 | - let lists = [].concat(event.file) | ||
372 | - let fileListLen = this[`fileList${event.name}`].length | ||
373 | - lists.map((item) => { | ||
374 | - this[`fileList${event.name}`].push({ | ||
375 | - ...item, | ||
376 | - status: 'uploading', | ||
377 | - message: '上传中' | ||
378 | - }) | ||
379 | - }) | ||
380 | - for (let i = 0; i < lists.length; i++) { | 432 | + // 删除图片 |
433 | + deletePic(event) { | ||
434 | + this[`fileList${event.name}`].splice(event.index, 1) | ||
435 | + }, | ||
436 | + // 新增图片 | ||
437 | + async afterRead(event) { | ||
438 | + // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 | ||
439 | + let lists = [].concat(event.file) | ||
440 | + let fileListLen = this[`fileList${event.name}`].length | ||
441 | + lists.map((item) => { | ||
442 | + this[`fileList${event.name}`].push({ | ||
443 | + ...item, | ||
444 | + status: 'uploading', | ||
445 | + message: '上传中' | ||
446 | + }) | ||
447 | + }) | ||
448 | + for (let i = 0; i < lists.length; i++) { | ||
381 | const result = await this.uploadFilePromise(lists[i].url) | 449 | const result = await this.uploadFilePromise(lists[i].url) |
382 | - console.log(result,'获取的结构'); | ||
383 | - let item = this[`fileList${event.name}`][fileListLen] | ||
384 | - this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, { | ||
385 | - status: 'success', | ||
386 | - message: '', | 450 | + console.log(result, '获取的结构'); |
451 | + let item = this[`fileList${event.name}`][fileListLen] | ||
452 | + this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, { | ||
453 | + status: 'success', | ||
454 | + message: '', | ||
387 | url: result.fullurl, | 455 | url: result.fullurl, |
388 | - shortUrl:result.url | ||
389 | - })) | ||
390 | - fileListLen++ | ||
391 | - } | ||
392 | - }, | ||
393 | - uploadFilePromise(url) { | ||
394 | - return new Promise((resolve, reject) => { | ||
395 | - let a = uni.uploadFile({ | ||
396 | - url: baseURL + 'common/upload', // 仅为示例,非真实的接口地址 | ||
397 | - filePath: url, | ||
398 | - name: 'file', | 456 | + shortUrl: result.url |
457 | + })) | ||
458 | + fileListLen++ | ||
459 | + } | ||
460 | + }, | ||
461 | + uploadFilePromise(url) { | ||
462 | + return new Promise((resolve, reject) => { | ||
463 | + let a = uni.uploadFile({ | ||
464 | + url: baseURL + 'common/upload', // 仅为示例,非真实的接口地址 | ||
465 | + filePath: url, | ||
466 | + name: 'file', | ||
399 | formData: { | 467 | formData: { |
400 | - token:uni.getStorageSync('token') || '' | ||
401 | - }, | ||
402 | - success: (res) => { | ||
403 | - setTimeout(() => { | ||
404 | - resolve(JSON.parse(res.data).data) | ||
405 | - }, 1000) | ||
406 | - } | ||
407 | - }); | ||
408 | - }) | 468 | + token: uni.getStorageSync('token') || '' |
469 | + }, | ||
470 | + success: (res) => { | ||
471 | + setTimeout(() => { | ||
472 | + resolve(JSON.parse(res.data).data) | ||
473 | + }, 1000) | ||
474 | + } | ||
475 | + }); | ||
476 | + }) | ||
409 | }, | 477 | }, |
410 | - selctCategory(e){ | ||
411 | - this.sortName = e.value[0].name | ||
412 | - this.form.sort_id = e.value[0].id | ||
413 | - this.showCategory = false | ||
414 | - console.log(e); | 478 | + selctCategory(e) { |
479 | + console.log(e) | ||
480 | + this.sortName = e.name | ||
481 | + this.form.sort_id = e.id | ||
482 | + this.isshowbox = false | ||
483 | + console.log(this.sortName,this.form.sort_id); | ||
415 | }, | 484 | }, |
416 | // 发布 | 485 | // 发布 |
417 | - send(){ | 486 | + send() { |
418 | console.log(this.lastInfo); | 487 | console.log(this.lastInfo); |
419 | - if(this.lastInfo.is_cert_withdraw!=1 ) return this.showmoney = true | ||
420 | - if(this.lastInfo.is_cert==0) return this.show = true | ||
421 | - if(this.fileList1.length){ | ||
422 | - this.form.images = this.fileList1.map(it=>it.shortUrl).join(',') | 488 | + if (this.lastInfo.is_cert_withdraw != 1) return this.showmoney = true |
489 | + if (this.lastInfo.is_cert == 0) return this.show = true | ||
490 | + if (this.fileList1.length) { | ||
491 | + this.form.images = this.fileList1.map(it => it.shortUrl).join(',') | ||
423 | } | 492 | } |
424 | console.log(this.form); | 493 | console.log(this.form); |
425 | this.sendProduct() | 494 | this.sendProduct() |
426 | }, | 495 | }, |
427 | - async sendProduct(){ | ||
428 | - try { | ||
429 | - const res = await sendProduct(this.form) | ||
430 | - console.log('sendProduct', res) | ||
431 | - setTimeout(()=>{ | ||
432 | - toa.success(this.form.product_id?'修改成功':'发布成功') | ||
433 | - },400) | ||
434 | - uni.redirectTo({ | ||
435 | - url:'/pages/mine/myRelease' | ||
436 | - }) | ||
437 | - // 保存数据 | ||
438 | - } catch (err) { | ||
439 | - uni.showToast({ title:err,icon:'none' }) | ||
440 | - console.log('sendProduct', err) | ||
441 | - } | 496 | + async sendProduct() { |
497 | + try { | ||
498 | + const res = await sendProduct(this.form) | ||
499 | + console.log('sendProduct', res) | ||
500 | + setTimeout(() => { | ||
501 | + toa.success(this.form.product_id ? '修改成功' : '发布成功') | ||
502 | + }, 400) | ||
503 | + uni.redirectTo({ | ||
504 | + url: '/pages/mine/myRelease' | ||
505 | + }) | ||
506 | + // 保存数据 | ||
507 | + } catch (err) { | ||
508 | + uni.showToast({ | ||
509 | + title: err, | ||
510 | + icon: 'none' | ||
511 | + }) | ||
512 | + console.log('sendProduct', err) | ||
513 | + } | ||
442 | }, | 514 | }, |
443 | - goRealName(){ | 515 | + goRealName() { |
444 | uni.navigateTo({ | 516 | uni.navigateTo({ |
445 | - url:'/pages/index/realName' | 517 | + url: '/pages/index/realName' |
446 | }) | 518 | }) |
447 | - | 519 | + |
448 | }, | 520 | }, |
449 | // 拿code | 521 | // 拿code |
450 | - async authorization(){ | ||
451 | - try { | ||
452 | - const openId = uni.getStorageSync('openId') | ||
453 | - if(openId) return this.userCertWithdraw() | ||
454 | - const res = await authorization(window.location.href) | ||
455 | - console.log('authorization', res) | ||
456 | - window.location.href = res.url | ||
457 | - // 保存数据 | ||
458 | - } catch (err) { | ||
459 | - uni.showToast({ title:err,icon:'none' }) | ||
460 | - console.log('authorization', err) | ||
461 | - } | 522 | + async authorization() { |
523 | + try { | ||
524 | + const openId = uni.getStorageSync('openId') | ||
525 | + if (openId) return this.userCertWithdraw() | ||
526 | + const res = await authorization(window.location.href) | ||
527 | + console.log('authorization', res) | ||
528 | + window.location.href = res.url | ||
529 | + // 保存数据 | ||
530 | + } catch (err) { | ||
531 | + uni.showToast({ | ||
532 | + title: err, | ||
533 | + icon: 'none' | ||
534 | + }) | ||
535 | + console.log('authorization', err) | ||
536 | + } | ||
462 | }, | 537 | }, |
463 | - | ||
464 | - } | ||
465 | - } | ||
466 | -</script> | ||
467 | - | ||
468 | -<style lang="scss"> | ||
469 | - page { | ||
470 | - background-color: #ffffff; | ||
471 | - } | ||
472 | - | ||
473 | - .Send { | ||
474 | - .contail { | ||
475 | - padding-bottom: 160rpx; | ||
476 | - | ||
477 | - .title { | ||
478 | - padding: 32rpx; | ||
479 | - box-sizing: border-box; | ||
480 | - color: rgba(0, 0, 0, 1); | ||
481 | - font-size: 28rpx; | ||
482 | - font-weight: 600; | ||
483 | - font-family: "PingFang SC"; | ||
484 | - } | ||
485 | - | ||
486 | - .main { | ||
487 | - padding: 0 32rpx; | ||
488 | - | ||
489 | - .bar { | ||
490 | - display: flex; | ||
491 | - align-items: center; | ||
492 | - justify-content: space-between; | ||
493 | - box-sizing: border-box; | ||
494 | - padding: 32rpx 0; | ||
495 | - border-bottom: 1px solid #F0f0f0; | ||
496 | - | ||
497 | - .name { | ||
498 | - color: rgba(0, 0, 0, 1); | ||
499 | - font-size: 28rpx; | ||
500 | - font-weight: 400; | ||
501 | - font-family: "PingFang SC"; | ||
502 | - | ||
503 | - text { | ||
504 | - color: rgba(252, 67, 56, 1); | ||
505 | - font-size: 28rpx; | ||
506 | - font-weight: 400; | ||
507 | - font-family: "PingFang SC"; | ||
508 | - } | ||
509 | - } | ||
510 | - | ||
511 | - .barchoose { | ||
512 | - | ||
513 | - color: rgba(0, 0, 0, 0.4); | ||
514 | - font-size: 28rpx; | ||
515 | - font-weight: 400; | ||
516 | - font-family: "PingFang SC"; | ||
517 | - image{ | ||
518 | - width: 24rpx; | ||
519 | - height: 16rpx; | ||
520 | - } | ||
521 | - } | ||
522 | - | ||
523 | - .barlast { | ||
524 | - display: flex; | ||
525 | - align-items: center; | ||
526 | - color: rgba(33, 83, 212, 1); | ||
527 | - font-size: 28rpx; | ||
528 | - font-weight: 400; | ||
529 | - font-family: "PingFang SC"; | ||
530 | - | ||
531 | - image { | ||
532 | - margin-left: 12rpx; | ||
533 | - width: 16rpx; | ||
534 | - height: 32rpx; | ||
535 | - } | ||
536 | - } | ||
537 | - | ||
538 | - input { | ||
539 | - text-align: right; | ||
540 | - } | ||
541 | - } | ||
542 | - | ||
543 | - .newbar { | ||
544 | - padding: 32rpx 0; | ||
545 | - box-sizing: border-box; | ||
546 | - border-bottom: 1px solid #F0f0f0; | ||
547 | - | ||
548 | - .name { | ||
549 | - color: rgba(0, 0, 0, 1); | ||
550 | - font-size: 28rpx; | ||
551 | - font-weight: 400; | ||
552 | - font-family: "PingFang SC"; | ||
553 | - } | ||
554 | - | ||
555 | - textarea { | ||
556 | - margin-top: 32rpx; | ||
557 | - padding: 24rpx; | ||
558 | - width: 100%; | ||
559 | - height: 200rpx; | ||
560 | - box-sizing: border-box; | ||
561 | - background-color: #F6F6F6; | ||
562 | - } | ||
563 | - | ||
564 | - .upimg { | ||
565 | - margin-top: 32rpx; | ||
566 | - } | ||
567 | - } | ||
568 | - | ||
569 | - } | ||
570 | - | ||
571 | - .popname { | ||
572 | - padding: 32rpx; | ||
573 | - box-sizing: border-box; | ||
574 | - width: 622rpx; | ||
575 | - text-align: center; | ||
576 | - | ||
577 | - .title { | ||
578 | - color: rgba(0, 0, 0, 0.9); | ||
579 | - font-size: 32rpx; | ||
580 | - font-weight: 600; | ||
581 | - font-family: "PingFang SC"; | ||
582 | - text-align: center; | ||
583 | - } | ||
584 | - | ||
585 | - .contant { | ||
586 | - color: rgba(179, 179, 179, 1); | ||
587 | - font-size: 28rpx; | ||
588 | - font-weight: 400; | ||
589 | - font-family: "PingFang SC"; | ||
590 | - text-align: center; | ||
591 | - } | ||
592 | - | ||
593 | - .btngroup { | ||
594 | - margin-top: 80rpx; | ||
595 | - display: flex; | ||
596 | - align-items: center; | ||
597 | - justify-content: space-between; | ||
598 | - | ||
599 | - .concle { | ||
600 | - width: 264rpx; | ||
601 | - height: 76rpx; | ||
602 | - border-radius: 16rpx; | ||
603 | - opacity: 1; | ||
604 | - line-height: 76rpx; | ||
605 | - color: rgba(0, 0, 0, 0.9); | ||
606 | - font-size: 28rpx; | ||
607 | - font-weight: 500; | ||
608 | - font-family: "PingFang SC"; | ||
609 | - text-align: center; | ||
610 | - background: rgba(246, 246, 246, 1); | ||
611 | - } | ||
612 | - | ||
613 | - .requt { | ||
614 | - width: 264rpx; | ||
615 | - height: 76rpx; | ||
616 | - color: rgba(0, 0, 0, 0.9); | ||
617 | - font-size: 28rpx; | ||
618 | - font-weight: 500; | ||
619 | - font-family: "PingFang SC"; | ||
620 | - text-align: center; | ||
621 | - line-height: 76rpx; | ||
622 | - border-radius: 16rpx; | ||
623 | - opacity: 1; | ||
624 | - background: rgba(254, 208, 0, 1); | ||
625 | - } | ||
626 | - } | ||
627 | - | ||
628 | - } | ||
629 | - | ||
630 | - .btn { | ||
631 | - position: fixed; | ||
632 | - bottom: 50rpx; | ||
633 | - left: 0; | ||
634 | - width: 100%; | ||
635 | - // height: 128rpx; | 538 | + |
539 | + } | ||
540 | + } | ||
541 | +</script> | ||
542 | + | ||
543 | +<style lang="scss"> | ||
544 | + page { | ||
545 | + background-color: #ffffff; | ||
546 | + } | ||
547 | + | ||
548 | + .Send { | ||
549 | + .contail { | ||
550 | + padding-bottom: 160rpx; | ||
551 | + | ||
552 | + .title { | ||
553 | + padding: 32rpx; | ||
554 | + box-sizing: border-box; | ||
555 | + color: rgba(0, 0, 0, 1); | ||
556 | + font-size: 28rpx; | ||
557 | + font-weight: 600; | ||
558 | + font-family: "PingFang SC"; | ||
559 | + } | ||
560 | + | ||
561 | + .main { | ||
562 | + padding: 0 32rpx; | ||
563 | + | ||
564 | + .bar { | ||
565 | + position: relative; | ||
566 | + display: flex; | ||
567 | + align-items: center; | ||
568 | + justify-content: space-between; | ||
569 | + box-sizing: border-box; | ||
570 | + padding: 32rpx 0; | ||
571 | + border-bottom: 1px solid #F0f0f0; | ||
572 | + | ||
573 | + .name { | ||
574 | + color: rgba(0, 0, 0, 1); | ||
575 | + font-size: 28rpx; | ||
576 | + font-weight: 400; | ||
577 | + font-family: "PingFang SC"; | ||
578 | + | ||
579 | + text { | ||
580 | + color: rgba(252, 67, 56, 1); | ||
581 | + font-size: 28rpx; | ||
582 | + font-weight: 400; | ||
583 | + font-family: "PingFang SC"; | ||
584 | + } | ||
585 | + } | ||
586 | + | ||
587 | + .barchoose { | ||
588 | + color: rgba(0, 0, 0, 0.4); | ||
589 | + font-size: 28rpx; | ||
590 | + font-weight: 400; | ||
591 | + font-family: "PingFang SC"; | ||
592 | + | ||
593 | + input { | ||
594 | + text-align: right; | ||
595 | + } | ||
596 | + | ||
597 | + image { | ||
598 | + width: 24rpx; | ||
599 | + height: 16rpx; | ||
600 | + } | ||
601 | + } | ||
602 | + | ||
603 | + .barlast { | ||
604 | + display: flex; | ||
605 | + align-items: center; | ||
606 | + color: rgba(33, 83, 212, 1); | ||
607 | + font-size: 28rpx; | ||
608 | + font-weight: 400; | ||
609 | + font-family: "PingFang SC"; | ||
610 | + | ||
611 | + image { | ||
612 | + margin-left: 12rpx; | ||
613 | + width: 16rpx; | ||
614 | + height: 32rpx; | ||
615 | + } | ||
616 | + } | ||
617 | + | ||
618 | + .nameinput { | ||
619 | + flex: 1; | ||
620 | + | ||
621 | + input { | ||
622 | + text-align: right; | ||
623 | + } | ||
624 | + } | ||
625 | + | ||
626 | + .barbox { | ||
627 | + position: absolute; | ||
628 | + right: 0; | ||
629 | + z-index: 99; | ||
630 | + bottom: -400rpx; | ||
631 | + padding: 0 24rpx; | ||
632 | + height: 400rpx; | ||
633 | + font-size: 28rpx; | ||
634 | + font-weight: 400; | ||
635 | + font-family: "PingFang SC"; | ||
636 | + box-sizing: border-box; | ||
637 | + background-color: #ffffff; | ||
638 | + border: 1px solid #F0f0f0; | ||
639 | + box-shadow: 5rpx 5rpx 5rpx rgba(0, 0, 0, 0.1); | ||
640 | + | ||
641 | + .bartip { | ||
642 | + padding: 24rpx 0; | ||
643 | + box-sizing: border-box; | ||
644 | + } | ||
645 | + } | ||
646 | + } | ||
647 | + | ||
648 | + .newbar { | ||
649 | + padding: 32rpx 0; | ||
650 | + box-sizing: border-box; | ||
651 | + border-bottom: 1px solid #F0f0f0; | ||
652 | + | ||
653 | + .name { | ||
654 | + color: rgba(0, 0, 0, 1); | ||
655 | + font-size: 28rpx; | ||
656 | + font-weight: 400; | ||
657 | + font-family: "PingFang SC"; | ||
658 | + } | ||
659 | + | ||
660 | + textarea { | ||
661 | + margin-top: 32rpx; | ||
662 | + padding: 24rpx; | ||
663 | + width: 100%; | ||
664 | + height: 200rpx; | ||
665 | + box-sizing: border-box; | ||
666 | + background-color: #F6F6F6; | ||
667 | + } | ||
668 | + | ||
669 | + .upimg { | ||
670 | + margin-top: 32rpx; | ||
671 | + } | ||
672 | + } | ||
673 | + | ||
674 | + } | ||
675 | + | ||
676 | + .popname { | ||
677 | + padding: 32rpx; | ||
678 | + box-sizing: border-box; | ||
679 | + width: 622rpx; | ||
680 | + text-align: center; | ||
681 | + | ||
682 | + .title { | ||
683 | + color: rgba(0, 0, 0, 0.9); | ||
684 | + font-size: 32rpx; | ||
685 | + font-weight: 600; | ||
686 | + font-family: "PingFang SC"; | ||
687 | + text-align: center; | ||
688 | + } | ||
689 | + | ||
690 | + .contant { | ||
691 | + color: rgba(179, 179, 179, 1); | ||
692 | + font-size: 28rpx; | ||
693 | + font-weight: 400; | ||
694 | + font-family: "PingFang SC"; | ||
695 | + text-align: center; | ||
696 | + } | ||
697 | + | ||
698 | + .btngroup { | ||
699 | + margin-top: 80rpx; | ||
700 | + display: flex; | ||
701 | + align-items: center; | ||
702 | + justify-content: space-between; | ||
703 | + | ||
704 | + .concle { | ||
705 | + width: 264rpx; | ||
706 | + height: 76rpx; | ||
707 | + border-radius: 16rpx; | ||
708 | + opacity: 1; | ||
709 | + line-height: 76rpx; | ||
710 | + color: rgba(0, 0, 0, 0.9); | ||
711 | + font-size: 28rpx; | ||
712 | + font-weight: 500; | ||
713 | + font-family: "PingFang SC"; | ||
714 | + text-align: center; | ||
715 | + background: rgba(246, 246, 246, 1); | ||
716 | + } | ||
717 | + | ||
718 | + .requt { | ||
719 | + width: 264rpx; | ||
720 | + height: 76rpx; | ||
721 | + color: rgba(0, 0, 0, 0.9); | ||
722 | + font-size: 28rpx; | ||
723 | + font-weight: 500; | ||
724 | + font-family: "PingFang SC"; | ||
725 | + text-align: center; | ||
726 | + line-height: 76rpx; | ||
727 | + border-radius: 16rpx; | ||
728 | + opacity: 1; | ||
729 | + background: rgba(254, 208, 0, 1); | ||
730 | + } | ||
731 | + } | ||
732 | + | ||
733 | + } | ||
734 | + | ||
735 | + .btn { | ||
736 | + position: fixed; | ||
737 | + bottom: 50rpx; | ||
738 | + left: 0; | ||
739 | + width: 100%; | ||
740 | + // height: 128rpx; | ||
636 | padding: 16rpx 32rpx; | 741 | padding: 16rpx 32rpx; |
637 | - padding-bottom: 100rpx; | ||
638 | - box-sizing: border-box; | ||
639 | - opacity: 1; | ||
640 | - background: rgba(255, 255, 255, 1); | ||
641 | - | ||
642 | - .paybtn { | ||
643 | - width: 100%; | ||
644 | - height: 96rpx; | ||
645 | - line-height: 96rpx; | ||
646 | - text-align: center; | ||
647 | - border-radius: 28rpx; | ||
648 | - opacity: 1; | ||
649 | - color: rgba(0, 0, 0, 0.9); | ||
650 | - font-size: 32rpx; | ||
651 | - font-weight: 600; | ||
652 | - font-family: "PingFang SC"; | ||
653 | - background: linear-gradient(134.8deg, rgba(255, 232, 100, 1) 0%, rgba(255, 216, 0, 1) 100%); | ||
654 | - } | ||
655 | - } | ||
656 | - | ||
657 | - } | 742 | + padding-bottom: 100rpx; |
743 | + box-sizing: border-box; | ||
744 | + opacity: 1; | ||
745 | + background: rgba(255, 255, 255, 1); | ||
746 | + | ||
747 | + .paybtn { | ||
748 | + width: 100%; | ||
749 | + height: 96rpx; | ||
750 | + line-height: 96rpx; | ||
751 | + text-align: center; | ||
752 | + border-radius: 28rpx; | ||
753 | + opacity: 1; | ||
754 | + color: rgba(0, 0, 0, 0.9); | ||
755 | + font-size: 32rpx; | ||
756 | + font-weight: 600; | ||
757 | + font-family: "PingFang SC"; | ||
758 | + background: linear-gradient(134.8deg, rgba(255, 232, 100, 1) 0%, rgba(255, 216, 0, 1) 100%); | ||
759 | + } | ||
760 | + } | ||
761 | + | ||
762 | + } | ||
658 | } | 763 | } |
659 | - | 764 | + |
660 | .u-textarea { | 765 | .u-textarea { |
661 | margin-top: 32rpx; | 766 | margin-top: 32rpx; |
662 | min-height: 200rpx; | 767 | min-height: 200rpx; |
663 | background: #f4f5f7; | 768 | background: #f4f5f7; |
664 | } | 769 | } |
770 | + | ||
665 | /deep/ .uni-textarea-wrapper { | 771 | /deep/ .uni-textarea-wrapper { |
666 | height: 100% !important; | 772 | height: 100% !important; |
667 | - } | 773 | + } |
668 | </style> | 774 | </style> |
1 | <template> | 1 | <template> |
2 | - <view class=""> | ||
3 | - <rich-text :nodes="text"></rich-text> | ||
4 | - </view> | ||
5 | -</template> | ||
6 | - | 2 | + <view class="" style="padding: 32rpx;"> |
3 | + <!-- <rich-text :nodes="text"></rich-text> --> | ||
4 | + <u-parse :content="text" noData="数据加载中..." @preview="preview" @navigate="navigate" ></u-parse> | ||
5 | + </view> | ||
6 | +</template> | ||
7 | + | ||
7 | <script> | 8 | <script> |
8 | - import { getAgreement } from '@/api/login.js' | 9 | + import { |
10 | + getAgreement | ||
11 | + } from '@/api/login.js' | ||
12 | + import uParse from '@/components/u-parse/u-parse.vue' | ||
9 | export default { | 13 | export default { |
14 | + components: { | ||
15 | + uParse | ||
16 | + }, | ||
10 | data() { | 17 | data() { |
11 | return { | 18 | return { |
12 | text: '', | 19 | text: '', |
13 | - type:'' | 20 | + type: '' |
14 | } | 21 | } |
15 | }, | 22 | }, |
16 | onLoad(e) { | 23 | onLoad(e) { |
17 | this.type = e.type | 24 | this.type = e.type |
18 | - wx.setNavigationBarTitle({ title: e.type==1?'用户协议':e.type==2?'隐私政策':'' }) | 25 | + wx.setNavigationBarTitle({ |
26 | + title: e.type == 1 ? '用户协议' : e.type == 2 ? '隐私政策' : '' | ||
27 | + }) | ||
19 | this.getAgreement() | 28 | this.getAgreement() |
20 | }, | 29 | }, |
21 | methods: { | 30 | methods: { |
22 | - async getAgreement(){ | ||
23 | - try { | ||
24 | - const res = await getAgreement(this.type) | ||
25 | - this.text = res.agreement | ||
26 | - console.log('getAgreement', res) | ||
27 | - // 保存数据 | ||
28 | - } catch (err) { | ||
29 | - uni.showToast({ title:err,icon:'none' }) | ||
30 | - console.log('getAgreement', err) | ||
31 | - } | 31 | + async getAgreement() { |
32 | + uni.showLoading({ | ||
33 | + title: '加载中', | ||
34 | + mask: true | ||
35 | + }) | ||
36 | + try { | ||
37 | + const res = await getAgreement(this.type) | ||
38 | + this.text = res.agreement | ||
39 | + uni.hideLoading(); | ||
40 | + // 保存数据 | ||
41 | + } catch (err) { | ||
42 | + uni.showToast({ title:err,icon:'none' }) | ||
43 | + } | ||
32 | }, | 44 | }, |
33 | }, | 45 | }, |
34 | - } | ||
35 | -</script> | ||
36 | - | ||
37 | -<style> | 46 | + } |
47 | +</script> | ||
48 | + | ||
49 | +<style> | ||
50 | + @import url("@/components/u-parse/u-parse.css"); | ||
38 | </style> | 51 | </style> |
@@ -5,10 +5,10 @@ | @@ -5,10 +5,10 @@ | ||
5 | 5 | ||
6 | <view class="bar flexwrap"> | 6 | <view class="bar flexwrap"> |
7 | <view class="name"> | 7 | <view class="name"> |
8 | - 用户名: | 8 | + 手机号: |
9 | </view> | 9 | </view> |
10 | <view class="last name"> | 10 | <view class="last name"> |
11 | - <input v-model="account" maxlength="16" type="text" value="" placeholder="请输入用户名" /> | 11 | + <input v-model="account" maxlength="16" type="text" value="" placeholder="请输入手机号" /> |
12 | </view> | 12 | </view> |
13 | </view> | 13 | </view> |
14 | <view class="bar flexwrap"> | 14 | <view class="bar flexwrap"> |
@@ -16,7 +16,7 @@ | @@ -16,7 +16,7 @@ | ||
16 | 密码: | 16 | 密码: |
17 | </view> | 17 | </view> |
18 | <view class="last name"> | 18 | <view class="last name"> |
19 | - <input v-model="password" maxlength="16" type="password" value="" placeholder="请输入密码" /> | 19 | + <input v-model="password" maxlength="16" type="password" value="" placeholder="请输入密码"/> |
20 | </view> | 20 | </view> |
21 | </view> | 21 | </view> |
22 | <view class="loginbtn" @click="doLogin"> | 22 | <view class="loginbtn" @click="doLogin"> |
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | 验证码: | 17 | 验证码: |
18 | </view> | 18 | </view> |
19 | <view class="lastname"> | 19 | <view class="lastname"> |
20 | - <input v-model="captcha" maxlength="" type="number" value="" placeholder="请输入验证码" /> | 20 | + <input v-model="captcha" maxlength="4" type="number" value="" placeholder="请输入验证码" /> |
21 | <view class="code" @click="getCode"> | 21 | <view class="code" @click="getCode"> |
22 | {{num==0?'获取验证码':num + '秒重新发送'}} | 22 | {{num==0?'获取验证码':num + '秒重新发送'}} |
23 | </view> | 23 | </view> |
-
请 注册 或 登录 后发表评论