作者 lihongjuan

1

@@ -2589,6 +2589,16 @@ @@ -2589,6 +2589,16 @@
2589 "integrity": "sha1-ACwZkJEtDVlYDJO9NsBW3pnkJZo=", 2589 "integrity": "sha1-ACwZkJEtDVlYDJO9NsBW3pnkJZo=",
2590 "dev": true 2590 "dev": true
2591 }, 2591 },
  2592 + "clipboard": {
  2593 + "version": "2.0.6",
  2594 + "resolved": "https://registry.npm.taobao.org/clipboard/download/clipboard-2.0.6.tgz",
  2595 + "integrity": "sha1-UpISlu7A/fd+rRdJQhshyWhkc3Y=",
  2596 + "requires": {
  2597 + "good-listener": "^1.2.2",
  2598 + "select": "^1.1.2",
  2599 + "tiny-emitter": "^2.0.0"
  2600 + }
  2601 + },
2592 "cliui": { 2602 "cliui": {
2593 "version": "4.1.0", 2603 "version": "4.1.0",
2594 "resolved": "https://registry.npm.taobao.org/cliui/download/cliui-4.1.0.tgz", 2604 "resolved": "https://registry.npm.taobao.org/cliui/download/cliui-4.1.0.tgz",
@@ -4314,6 +4324,11 @@ @@ -4314,6 +4324,11 @@
4314 "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", 4324 "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
4315 "dev": true 4325 "dev": true
4316 }, 4326 },
  4327 + "delegate": {
  4328 + "version": "3.2.0",
  4329 + "resolved": "https://registry.npm.taobao.org/delegate/download/delegate-3.2.0.tgz",
  4330 + "integrity": "sha1-tmtxwxWFIuirV0T3INjKDCr1kWY="
  4331 + },
4317 "depd": { 4332 "depd": {
4318 "version": "1.1.2", 4333 "version": "1.1.2",
4319 "resolved": "https://registry.npm.taobao.org/depd/download/depd-1.1.2.tgz", 4334 "resolved": "https://registry.npm.taobao.org/depd/download/depd-1.1.2.tgz",
@@ -5553,6 +5568,14 @@ @@ -5553,6 +5568,14 @@
5553 "pinkie-promise": "^2.0.0" 5568 "pinkie-promise": "^2.0.0"
5554 } 5569 }
5555 }, 5570 },
  5571 + "good-listener": {
  5572 + "version": "1.2.2",
  5573 + "resolved": "https://registry.npm.taobao.org/good-listener/download/good-listener-1.2.2.tgz",
  5574 + "integrity": "sha1-1TswzfkxPf+33JoNR3CWqm0UXFA=",
  5575 + "requires": {
  5576 + "delegate": "^3.1.2"
  5577 + }
  5578 + },
5556 "graceful-fs": { 5579 "graceful-fs": {
5557 "version": "4.2.4", 5580 "version": "4.2.4",
5558 "resolved": "https://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.2.4.tgz?cache=0&sync_timestamp=1588086905523&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fgraceful-fs%2Fdownload%2Fgraceful-fs-4.2.4.tgz", 5581 "resolved": "https://registry.npm.taobao.org/graceful-fs/download/graceful-fs-4.2.4.tgz?cache=0&sync_timestamp=1588086905523&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fgraceful-fs%2Fdownload%2Fgraceful-fs-4.2.4.tgz",
@@ -12621,6 +12644,11 @@ @@ -12621,6 +12644,11 @@
12621 } 12644 }
12622 } 12645 }
12623 }, 12646 },
  12647 + "select": {
  12648 + "version": "1.1.2",
  12649 + "resolved": "https://registry.npm.taobao.org/select/download/select-1.1.2.tgz",
  12650 + "integrity": "sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0="
  12651 + },
12624 "select-hose": { 12652 "select-hose": {
12625 "version": "2.0.0", 12653 "version": "2.0.0",
12626 "resolved": "https://registry.npm.taobao.org/select-hose/download/select-hose-2.0.0.tgz", 12654 "resolved": "https://registry.npm.taobao.org/select-hose/download/select-hose-2.0.0.tgz",
@@ -13645,6 +13673,11 @@ @@ -13645,6 +13673,11 @@
13645 "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=", 13673 "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=",
13646 "dev": true 13674 "dev": true
13647 }, 13675 },
  13676 + "tiny-emitter": {
  13677 + "version": "2.1.0",
  13678 + "resolved": "https://registry.npm.taobao.org/tiny-emitter/download/tiny-emitter-2.1.0.tgz",
  13679 + "integrity": "sha1-HRpW7fxRxD6GPLtTgqcjMONVVCM="
  13680 + },
13648 "tmpl": { 13681 "tmpl": {
13649 "version": "1.0.4", 13682 "version": "1.0.4",
13650 "resolved": "https://registry.npm.taobao.org/tmpl/download/tmpl-1.0.4.tgz", 13683 "resolved": "https://registry.npm.taobao.org/tmpl/download/tmpl-1.0.4.tgz",
@@ -14216,6 +14249,14 @@ @@ -14216,6 +14249,14 @@
14216 "resolved": "https://registry.npm.taobao.org/vue/download/vue-2.6.11.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue%2Fdownload%2Fvue-2.6.11.tgz", 14249 "resolved": "https://registry.npm.taobao.org/vue/download/vue-2.6.11.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue%2Fdownload%2Fvue-2.6.11.tgz",
14217 "integrity": "sha1-dllNh31LEiNEBuhONSdcbVFBJcU=" 14250 "integrity": "sha1-dllNh31LEiNEBuhONSdcbVFBJcU="
14218 }, 14251 },
  14252 + "vue-clipboard2": {
  14253 + "version": "0.3.1",
  14254 + "resolved": "https://registry.npm.taobao.org/vue-clipboard2/download/vue-clipboard2-0.3.1.tgz",
  14255 + "integrity": "sha1-blUft704SImyiw2jsSKJ7WvKSJQ=",
  14256 + "requires": {
  14257 + "clipboard": "^2.0.0"
  14258 + }
  14259 + },
14219 "vue-hot-reload-api": { 14260 "vue-hot-reload-api": {
14220 "version": "2.3.4", 14261 "version": "2.3.4",
14221 "resolved": "https://registry.npm.taobao.org/vue-hot-reload-api/download/vue-hot-reload-api-2.3.4.tgz", 14262 "resolved": "https://registry.npm.taobao.org/vue-hot-reload-api/download/vue-hot-reload-api-2.3.4.tgz",
@@ -14,8 +14,10 @@ @@ -14,8 +14,10 @@
14 }, 14 },
15 "dependencies": { 15 "dependencies": {
16 "axios": "^0.19.2", 16 "axios": "^0.19.2",
  17 + "clipboard": "^2.0.6",
17 "vant": "^2.9.2", 18 "vant": "^2.9.2",
18 "vue": "^2.5.2", 19 "vue": "^2.5.2",
  20 + "vue-clipboard2": "^0.3.1",
19 "vue-router": "^3.0.1", 21 "vue-router": "^3.0.1",
20 "weixin-js-sdk": "^1.6.0" 22 "weixin-js-sdk": "^1.6.0"
21 }, 23 },
@@ -7,7 +7,11 @@ @@ -7,7 +7,11 @@
7 <img src="../../../assets/search.png" alt /> 7 <img src="../../../assets/search.png" alt />
8 </div> 8 </div>
9 9
10 - <input type="text" placeholder="搜索你感兴趣的课程文章" class="searchtext" /> 10 + <input
  11 + type="text"
  12 + placeholder="搜索你感兴趣的课程文章"
  13 + class="searchtext"
  14 + />
11 </div> 15 </div>
12 </div> 16 </div>
13 <!-- 课程列表 --> 17 <!-- 课程列表 -->
@@ -57,17 +61,21 @@ @@ -57,17 +61,21 @@
57 :class="selnav == 0 ? 'selactive' : ''" 61 :class="selnav == 0 ? 'selactive' : ''"
58 :data-id="0" 62 :data-id="0"
59 @click="selectnav" 63 @click="selectnav"
60 - >音频课程</div> 64 + >
  65 + 音频课程
  66 + </div>
61 <div 67 <div
62 class="coursenavleft" 68 class="coursenavleft"
63 :class="selnav == 1 ? 'selactive' : ''" 69 :class="selnav == 1 ? 'selactive' : ''"
64 :data-id="1" 70 :data-id="1"
65 @click="selectnav" 71 @click="selectnav"
66 - >营养小知识</div> 72 + >
  73 + 营养小知识
  74 + </div>
67 </div> 75 </div>
68 <!-- 课程 --> 76 <!-- 课程 -->
69 <div v-if="selnav == 0"> 77 <div v-if="selnav == 0">
70 - <div class="nodata" v-if="videolist.length==0">暂无数据</div> 78 + <div class="nodata" v-if="videolist.length == 0">暂无数据</div>
71 <van-list 79 <van-list
72 class="courseboxk" 80 class="courseboxk"
73 v-model="loading" 81 v-model="loading"
@@ -81,9 +89,9 @@ @@ -81,9 +89,9 @@
81 <img :src="item.image" alt /> 89 <img :src="item.image" alt />
82 </div> 90 </div>
83 <div class="coursetext"> 91 <div class="coursetext">
84 - <div class="coursetitle">{{item.title}}</div>  
85 - <div class="coursename">{{item.description}}</div>  
86 - <div class="courseteacher">{{item.user.nickname}}</div> 92 + <div class="coursetitle">{{ item.title }}</div>
  93 + <div class="coursename">{{ item.description }}</div>
  94 + <div class="courseteacher">{{ item.user.nickname }}</div>
87 </div> 95 </div>
88 </div> 96 </div>
89 </van-list> 97 </van-list>
@@ -91,7 +99,7 @@ @@ -91,7 +99,7 @@
91 99
92 <!-- 营养小知识 --> 100 <!-- 营养小知识 -->
93 <div v-if="selnav == 1"> 101 <div v-if="selnav == 1">
94 - <div class="nodata" v-if="yinglist.length==0">暂无数据</div> 102 + <div class="nodata" v-if="yinglist.length == 0">暂无数据</div>
95 <van-list 103 <van-list
96 class="courseboxk" 104 class="courseboxk"
97 v-model="loadingying" 105 v-model="loadingying"
@@ -122,9 +130,9 @@ @@ -122,9 +130,9 @@
122 </template> 130 </template>
123 131
124 <script> 132 <script>
125 -import Vue from 'vue'; 133 +import Vue from "vue";
126 import tabBar from "@/components/views/tabBar.vue"; 134 import tabBar from "@/components/views/tabBar.vue";
127 -import { List } from 'vant'; 135 +import { List } from "vant";
128 Vue.use(List); 136 Vue.use(List);
129 export default { 137 export default {
130 components: { 138 components: {
@@ -141,13 +149,12 @@ export default { @@ -141,13 +149,12 @@ export default {
141 finishedying: false, 149 finishedying: false,
142 yinglist: [], 150 yinglist: [],
143 videopage: 1, 151 videopage: 1,
144 - this_page: '',  
145 - total_page: ''  
146 - 152 + this_page: "",
  153 + total_page: ""
147 }; 154 };
148 }, 155 },
149 created() { 156 created() {
150 - this.getvideolist() 157 + this.getvideolist();
151 }, 158 },
152 methods: { 159 methods: {
153 // 视频上拉加载 160 // 视频上拉加载
@@ -156,13 +163,13 @@ export default { @@ -156,13 +163,13 @@ export default {
156 // 异步更新数据 163 // 异步更新数据
157 // setTimeout 仅做示例,真实场景中一般为 ajax 请求 164 // setTimeout 仅做示例,真实场景中一般为 ajax 请求
158 setTimeout(() => { 165 setTimeout(() => {
159 - console.log(3434) 166 + console.log(3434);
160 167
161 - let newvideopage = that.videopage 168 + let newvideopage = that.videopage;
162 newvideopage++; 169 newvideopage++;
163 that.videopage = newvideopage; 170 that.videopage = newvideopage;
164 - console.log(that.videopage)  
165 - that.getvideolist() 171 + console.log(that.videopage);
  172 + that.getvideolist();
166 173
167 // 加载状态结束 174 // 加载状态结束
168 this.loading = false; 175 this.loading = false;
@@ -179,13 +186,13 @@ export default { @@ -179,13 +186,13 @@ export default {
179 // 异步更新数据 186 // 异步更新数据
180 // setTimeout 仅做示例,真实场景中一般为 ajax 请求 187 // setTimeout 仅做示例,真实场景中一般为 ajax 请求
181 setTimeout(() => { 188 setTimeout(() => {
182 - console.log(3434) 189 + console.log(3434);
183 190
184 - let newvideopage = that.videopage 191 + let newvideopage = that.videopage;
185 newvideopage++; 192 newvideopage++;
186 that.videopage = newvideopage; 193 that.videopage = newvideopage;
187 - console.log(that.videopage)  
188 - that.getyingyang() 194 + console.log(that.videopage);
  195 + that.getyingyang();
189 196
190 // 加载状态结束 197 // 加载状态结束
191 this.loadingying = false; 198 this.loadingying = false;
@@ -204,14 +211,13 @@ export default { @@ -204,14 +211,13 @@ export default {
204 page: that.videopage 211 page: that.videopage
205 }; 212 };
206 213
207 -  
208 that.$axios 214 that.$axios
209 .post(url, param, Headers) 215 .post(url, param, Headers)
210 .then(res => { 216 .then(res => {
211 console.log(res, "列表"); 217 console.log(res, "列表");
212 - that.videolist = that.videolist.concat(res.data.lesson) 218 + that.videolist = that.videolist.concat(res.data.lesson);
213 that.total_page = res.data.total_page; 219 that.total_page = res.data.total_page;
214 - that.this_page = res.data.this_page 220 + that.this_page = res.data.this_page;
215 }) 221 })
216 .catch(err => { 222 .catch(err => {
217 console.log(err); 223 console.log(err);
@@ -223,7 +229,7 @@ export default { @@ -223,7 +229,7 @@ export default {
223 }, 229 },
224 // 获取营养知识 230 // 获取营养知识
225 getyingyang() { 231 getyingyang() {
226 - console.log(9999) 232 + console.log(9999);
227 let that = this; 233 let that = this;
228 var url = "/api/index/knowledge_list"; 234 var url = "/api/index/knowledge_list";
229 let param = { 235 let param = {
@@ -233,14 +239,13 @@ export default { @@ -233,14 +239,13 @@ export default {
233 .post(url, param) 239 .post(url, param)
234 .then(res => { 240 .then(res => {
235 console.log(res, "列表"); 241 console.log(res, "列表");
236 - that.yinglist = that.yinglist.concat(res.data.knowledge) 242 + that.yinglist = that.yinglist.concat(res.data.knowledge);
237 that.total_page = res.data.total_page; 243 that.total_page = res.data.total_page;
238 - that.this_page = res.data.this_page 244 + that.this_page = res.data.this_page;
239 }) 245 })
240 .catch(err => { 246 .catch(err => {
241 console.log(err); 247 console.log(err);
242 248
243 -  
244 // setTimeout(function () { 249 // setTimeout(function () {
245 // that.$router.go(-1) 250 // that.$router.go(-1)
246 // }) 251 // })
@@ -256,19 +261,19 @@ export default { @@ -256,19 +261,19 @@ export default {
256 selectnav(e) { 261 selectnav(e) {
257 let that = this; 262 let that = this;
258 this.selnav = e.currentTarget.dataset.id; 263 this.selnav = e.currentTarget.dataset.id;
259 - console.log(this.selnav) 264 + console.log(this.selnav);
260 if (this.selnav == 0) { 265 if (this.selnav == 0) {
261 - that.total_page = ''  
262 - that.this_page = ''  
263 - that.videopage = 1  
264 - that.videolist = []  
265 - this.getvideolist() 266 + that.total_page = "";
  267 + that.this_page = "";
  268 + that.videopage = 1;
  269 + that.videolist = [];
  270 + this.getvideolist();
266 } else if (this.selnav == 1) { 271 } else if (this.selnav == 1) {
267 - that.total_page = ''  
268 - that.this_page = ''  
269 - this.yinglist = []  
270 - that.videopage = 1  
271 - this.getyingyang() 272 + that.total_page = "";
  273 + that.this_page = "";
  274 + this.yinglist = [];
  275 + that.videopage = 1;
  276 + this.getyingyang();
272 } 277 }
273 } 278 }
274 } 279 }
@@ -3,30 +3,43 @@ @@ -3,30 +3,43 @@
3 <div class="topcontainer"> 3 <div class="topcontainer">
4 <div class="publishitem flextwo" @click="selectkind"> 4 <div class="publishitem flextwo" @click="selectkind">
5 <div class="publeft flexone"> 5 <div class="publeft flexone">
6 - <div class="kindname">{{kindname}}</div>  
7 - <div class="pubpicker" v-if="false">  
8 - <van-picker  
9 - show-toolbar  
10 - :columns="columns"  
11 - @confirm="onConfirm"  
12 - @cancel="onCancel"  
13 - @change="onChange"  
14 - /> 6 + <div class="kindname">
  7 + <span class="kindleft">分类</span>
  8 + {{kindname}}
15 </div> 9 </div>
16 </div> 10 </div>
17 11
18 <img src="../../../assets/grayrow.png" alt class="yourow" /> 12 <img src="../../../assets/grayrow.png" alt class="yourow" />
19 </div> 13 </div>
20 <div class="enterkind"> 14 <div class="enterkind">
21 - <textarea name id cols="30" rows="10" placeholder="请输入您的想法"></textarea> 15 + <textarea name id cols="30" rows="10" placeholder="请输入您的想法" v-model="kindidea"></textarea>
22 </div> 16 </div>
23 - <div class="pubimg">  
24 - <img src="../../../assets/addpub.png" alt /> 17 +
  18 + <div>
  19 + <van-uploader
  20 + v-model="fileList"
  21 + multiple="true"
  22 + :after-read="afterRead"
  23 + :max-count="8"
  24 + @delete="deleftimg"
  25 + />
  26 +
  27 + <!-- <div class="pubimg">
  28 + <img src="../../../assets/addpub.png" alt />
  29 + </div>-->
25 </div> 30 </div>
26 </div> 31 </div>
27 32
28 - <div class="kaishilu">发布</div>  
29 - 33 + <div class="kaishilu" @click="publish">发布</div>
  34 + <div class="pubpicker" v-if="showkind">
  35 + <van-picker
  36 + show-toolbar
  37 + :columns="columns"
  38 + @confirm="onConfirm"
  39 + @cancel="onCancel"
  40 + @setValues="getvalue"
  41 + />
  42 + </div>
30 <!-- 发布成功 --> 43 <!-- 发布成功 -->
31 <div class="register" v-if="success"> 44 <div class="register" v-if="success">
32 <div class="pubsuccess"> 45 <div class="pubsuccess">
@@ -39,18 +52,30 @@ @@ -39,18 +52,30 @@
39 52
40 <script> 53 <script>
41 import Vue from 'vue'; 54 import Vue from 'vue';
42 -import { Picker } from 'vant';  
43 - 55 +import { Picker, Uploader, Toast } from 'vant';
  56 +import "vant/lib/index.css";
44 Vue.use(Picker); 57 Vue.use(Picker);
  58 +Vue.use(Toast);
  59 +Vue.use(Uploader);
45 export default { 60 export default {
46 data() { 61 data() {
47 return { 62 return {
48 - columns: ['杭州', '宁波', '温州', '嘉兴', '湖州'], 63 + columns: [],
49 showkind: false, 64 showkind: false,
50 - kindname: '分类一',  
51 - success: false 65 + kindname: '请选择分类',
  66 + success: false,
  67 + kindidea: '',
  68 + fileList: [],
  69 + images: [],
  70 + chuanimage: [],
  71 + delimg: [],
  72 + sort: [],
  73 + sort_id: ''
52 } 74 }
53 }, 75 },
  76 + created() {
  77 + this.getkindlist()
  78 + },
54 methods: { 79 methods: {
55 selectkind() { 80 selectkind() {
56 this.showkind = true 81 this.showkind = true
@@ -63,26 +88,147 @@ export default { @@ -63,26 +88,147 @@ export default {
63 onConfirm(value, index) { 88 onConfirm(value, index) {
64 console.log(78343784) 89 console.log(78343784)
65 this.showkind = false 90 this.showkind = false
66 - console.log(this.showkind) 91 + this.kindname = value
  92 + this.sort_id = this.sort[index].id
67 93
68 }, 94 },
69 - onChange(picker, value, index) {  
70 95
71 - },  
72 sure() { 96 sure() {
73 this.success = false 97 this.success = false
74 }, 98 },
  99 + // 上传图片
  100 + afterRead(file) {
  101 + let that = this;
  102 + console.log(file)
  103 + console.log(file.length)
  104 + if (file.length == undefined) {
  105 + var formdata = new FormData();
  106 + formdata.append("file", file.file);
  107 + that.delimg.push(file.file.name)
  108 + var url = "/api/common/upload";
  109 + let param = {
  110 + id: 1
  111 + }
  112 +
  113 + that
  114 + .$uploadFile.post(url, formdata)
  115 + .then(function (res) {
  116 + console.log(res);
  117 + that.cardzheng = false
  118 + let url = "http://tangyuanji.t.brotop.cn" + res.data.url;
  119 + that.images.push(url);
  120 + that.chuanimage.push(res.data.url);
  121 +
  122 +
  123 + })
  124 + .catch(err => {
  125 + console.log(err);
  126 + });
  127 +
  128 + } else {
  129 + for (var i = 0; i < file.length; i++) {
  130 + console.log(file[i].file)
  131 +
  132 + var formdata = new FormData();
  133 + formdata.append("file", file[i].file);
  134 + that.delimg.push(file[i].file.name)
  135 +
  136 + var url = "/api/common/upload";
  137 +
  138 + that
  139 + .$uploadFile.post(url, formdata)
  140 + .then(function (res) {
  141 + console.log(res);
  142 + that.cardzheng = false
  143 + let url = "http://tangyuanji.t.brotop.cn" + res.data.url;
  144 + that.images.push(url);
  145 + that.chuanimage.push(res.data.url);
  146 +
  147 + })
  148 + .catch(err => {
  149 + console.log(err);
  150 + });
  151 + }
  152 +
  153 +
  154 + }
  155 + },
  156 +
  157 + // 删除文件
  158 + deleftimg(e) {
  159 + let that = this;
  160 + let item = e.file.name
  161 + this.delimg.forEach(function (value, index, array) {
  162 + if (value == item) {
  163 + that.delimg.splice(index, 1);
  164 + that.images.splice(index, 1);
  165 + that.chuanimage.splice(index, 1);
  166 + }
  167 + });
  168 + this.delimg = this.delimg
  169 + this.images = this.images;
  170 + this.chuanimage = this.chuanimage;
  171 +
  172 + this.$forceUpdate();
  173 +
  174 + },
  175 + // 获取分类列表
  176 + getkindlist() {
  177 + let that = this;
  178 + var url = "/api/social/sort";
  179 + let param = {
  180 +
  181 + };
  182 +
  183 + that.$axios
  184 + .post(url, param)
  185 + .then(function (res) {
  186 + console.log(res);
  187 + let data = res.data;
  188 + data.forEach(function (value, index) {
  189 + that.columns.push(value.sort_name)
  190 + })
  191 + that.columns = that.columns
  192 + that.sort = res.data
  193 +
  194 +
  195 + })
  196 + .catch(function (err) {
  197 + console.log(err);
  198 + });
  199 + },
  200 + getvalue(value) {
  201 + console.log(value)
  202 + },
  203 + // 发布
75 publish() { 204 publish() {
76 let that = this; 205 let that = this;
77 - var url = "/api/user/authorize"; 206 + var url = "/api/social/send";
  207 + if (that.sort_id == '') {
  208 + Toast("请选择分类")
  209 + return false
  210 + }
  211 + if (that.kindidea == '') {
  212 + Toast("请输入您的想法")
  213 + return false
  214 + }
  215 + if (that.chuanimage.length != that.fileList.length) {
  216 + Toast("图片上传中")
  217 + return false
  218 + }
78 let param = { 219 let param = {
79 - redirect_uri: urlk 220 + sort_id: that.sort_id,
  221 + description: that.kindidea,
  222 + images: that.chuanimage.join(",")
80 }; 223 };
81 224
82 that.$axios 225 that.$axios
83 .post(url, param) 226 .post(url, param)
84 .then(function (res) { 227 .then(function (res) {
85 console.log(res); 228 console.log(res);
  229 + Toast("发布成功")
  230 + that.$router.go(-1)
  231 +
86 232
87 }) 233 })
88 .catch(function (err) { 234 .catch(function (err) {
@@ -103,4 +249,9 @@ export default { @@ -103,4 +249,9 @@ export default {
103 padding-bottom: 0.32rem; 249 padding-bottom: 0.32rem;
104 box-sizing: border-box; 250 box-sizing: border-box;
105 } 251 }
  252 +.kindleft {
  253 + color: #323233;
  254 + font-size: 0.28rem;
  255 + margin-right: 0.32rem;
  256 +}
106 </style> 257 </style>
@@ -4,56 +4,110 @@ @@ -4,56 +4,110 @@
4 <div 4 <div
5 class="coursenavleft" 5 class="coursenavleft"
6 :class="selnav == index ? 'selactive' : ''" 6 :class="selnav == index ? 'selactive' : ''"
7 - @click="selectnav(item.id,index)" 7 + @click="selectnav(item.id, index)"
8 v-for="(item, index) in navarr" 8 v-for="(item, index) in navarr"
9 :key="index" 9 :key="index"
10 - >{{ item.sort_name }}</div> 10 + >
  11 + {{ item.sort_name }}
  12 + </div>
11 </div> 13 </div>
12 <div class="societybox"> 14 <div class="societybox">
13 - <div class="nodata" v-if="sortlist.length==0">暂无数据</div>  
14 - <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad" v-else>  
15 - <div class="societyitem" v-for="item in sortlist" :key="item.id"> 15 + <div class="nodata" v-if="sortlist.length == 0">暂无数据</div>
  16 + <van-list
  17 + v-model="loading"
  18 + :finished="finished"
  19 + finished-text="没有更多了"
  20 + @load="onLoad"
  21 + v-else
  22 + >
  23 + <div class="societyitem" v-for="(item, index) in sortlist" :key="index">
16 <div class="societytop flextwo"> 24 <div class="societytop flextwo">
17 <div class="societyleft flexone"> 25 <div class="societyleft flexone">
18 <div class="personimg"> 26 <div class="personimg">
19 <img :src="item.user.avatar" alt /> 27 <img :src="item.user.avatar" alt />
20 </div> 28 </div>
21 <div class="personright"> 29 <div class="personright">
22 - <div class="personname">{{item.user.nickname}}</div>  
23 - <div class="persondate">{{item.createtime}}</div> 30 + <div class="personname">{{ item.user.nickname }}</div>
  31 + <div class="persondate">{{ item.createtime }}</div>
24 </div> 32 </div>
25 </div> 33 </div>
26 - <div class="dingimg" v-if="item.is_top==1"> 34 + <div class="dingimg" v-if="item.is_top == 1">
27 <img src="../../../assets/ding.png" alt /> 35 <img src="../../../assets/ding.png" alt />
28 </div> 36 </div>
29 </div> 37 </div>
30 - <div class="societytext">{{item.description}}</div>  
31 - <div class="societyimg flexone" v-if="item.images_arr.length!=0">  
32 - <div class="societyimgitem" v-for="item in item.images_arr" :key="item">  
33 - <img src="../../../assets/societyimg.png" alt /> 38 + <div class="societytext">{{ item.description }}</div>
  39 + <div class="societyimg flexone" v-if="item.images_arr.length != 0">
  40 + <div
  41 + class="societyimgitem"
  42 + v-for="(item, indexk) in item.images_arr"
  43 + :key="indexk"
  44 + @click="previewimg(index, indexk)"
  45 + >
  46 + <img :src="item" alt />
34 </div> 47 </div>
35 </div> 48 </div>
36 - <div class="jianzheng flexone">  
37 - <div class="jianzhengleft">#</div>  
38 - <div class="jianzhengright">见证蜕变</div> 49 + <div class="jianzhengtui flexone">
  50 + <div
  51 + class="jianzheng flexone"
  52 + v-for="(item, index) in item.tags"
  53 + :key="index"
  54 + >
  55 + <div class="jianzhengleft" :style="{ background: item.color }">
  56 + #
  57 + </div>
  58 + <div class="jianzhengright" :style="{ color: item.color }">
  59 + {{ item.name }}
  60 + </div>
  61 + </div>
39 </div> 62 </div>
  63 +
40 <!-- 点赞 --> 64 <!-- 点赞 -->
41 <div class="dainzan flexone"> 65 <div class="dainzan flexone">
42 - <div class="flexone dianitem">  
43 - <img src="../../../assets/zan.png" alt class="dianzanimg" />  
44 - <span class="number">960</span> 66 + <div class="flexone dianitem" @click="zanclick(index, item)">
  67 + <img
  68 + src="../../../assets/diankong.png"
  69 + alt
  70 + class="dianzanimg"
  71 + v-if="item.is_good == 0"
  72 + />
  73 + <img
  74 + src="../../../assets/zan.png"
  75 + alt
  76 + class="dianzanimg"
  77 + v-else
  78 + />
  79 + <span class="number">{{ item.good_count }}</span>
45 </div> 80 </div>
46 - <div class="flexone dianitem">  
47 - <img src="../../../assets/star.png" alt class="dianzanimg" />  
48 - <span class="number">960</span> 81 + <div class="flexone dianitem" @click="collect(index, item)">
  82 + <img
  83 + src="../../../assets/starkong.png"
  84 + alt
  85 + class="dianzanimg"
  86 + v-if="item.is_favorite == 0"
  87 + />
  88 + <img
  89 + src="../../../assets/star.png"
  90 + alt
  91 + class="dianzanimg"
  92 + v-else
  93 + />
  94 +
  95 + <span class="number">{{ item.favorite_count }}</span>
49 </div> 96 </div>
50 - <div class="flexone dianitem"> 97 + <div class="flexone dianitem" @click="copytext">
51 <img src="../../../assets/edit.png" alt class="dianzanimg" /> 98 <img src="../../../assets/edit.png" alt class="dianzanimg" />
52 - <span class="number">960</span> 99 + <!-- <span class="number">复制文本</span> -->
  100 + <span
  101 + class="number"
  102 + v-clipboard:copy="item.description"
  103 + v-clipboard:success="onCopy"
  104 + >复制</span
  105 + >
  106 + <!-- v-clipboard:error="onError" -->
53 </div> 107 </div>
54 - <div class="flexone dianitem"> 108 + <div class="flexone dianitem" @click="save(item)">
55 <img src="../../../assets/download.png" alt class="dianzanimg" /> 109 <img src="../../../assets/download.png" alt class="dianzanimg" />
56 - <span class="number">960</span> 110 + <span class="number">一键保存</span>
57 </div> 111 </div>
58 </div> 112 </div>
59 </div> 113 </div>
@@ -61,11 +115,19 @@ @@ -61,11 +115,19 @@
61 </div> 115 </div>
62 116
63 <!-- 图片没有上传 --> 117 <!-- 图片没有上传 -->
64 - <div class="gantanimg" v-if="nophoto"> 118 + <div class="gantanimg" v-if="nophoto" @click="nophotoup">
65 <img src="../../../assets/gantan.png" class="ganimg" alt /> 119 <img src="../../../assets/gantan.png" class="ganimg" alt />
66 <div class="gantantext">用户未上传图片</div> 120 <div class="gantantext">用户未上传图片</div>
67 </div> 121 </div>
68 - 122 + <!-- 预览图片 -->
  123 + <van-image-preview
  124 + v-model="show"
  125 + :images="images"
  126 + @change="onChange"
  127 + :startPosition="startPosition"
  128 + >
  129 + <template v-slot:index>第{{ index + 1 }}页</template>
  130 + </van-image-preview>
69 <!-- 添加 --> 131 <!-- 添加 -->
70 <div class="addimg" @click="publish"> 132 <div class="addimg" @click="publish">
71 <img src="../../../assets/add.png" alt /> 133 <img src="../../../assets/add.png" alt />
@@ -76,10 +138,12 @@ @@ -76,10 +138,12 @@
76 138
77 <script> 139 <script>
78 import tabBar from "@/components/views/tabBar.vue"; 140 import tabBar from "@/components/views/tabBar.vue";
79 -import Vue from 'vue';  
80 -import { List } from 'vant'; 141 +import Vue from "vue";
  142 +import { List, Toast, ImagePreview } from "vant";
  143 +Vue.use(ImagePreview);
81 144
82 Vue.use(List); 145 Vue.use(List);
  146 +
83 export default { 147 export default {
84 components: { 148 components: {
85 tabBar 149 tabBar
@@ -88,22 +152,57 @@ export default { @@ -88,22 +152,57 @@ export default {
88 return { 152 return {
89 selnav: 0, 153 selnav: 0,
90 navarr: [], 154 navarr: [],
91 - sort_id: '', 155 + sort_id: "",
92 nophoto: false, 156 nophoto: false,
93 sortlist: [], 157 sortlist: [],
94 loading: false, 158 loading: false,
95 finished: false, 159 finished: false,
96 page: 1, 160 page: 1,
97 - this_page: '',  
98 - total_page: '' 161 + this_page: "",
  162 + total_page: "",
  163 + show: false,
  164 + index: 0,
  165 + images: [],
  166 + startPosition: 0
99 }; 167 };
100 }, 168 },
101 created() { 169 created() {
102 - this.getsort() 170 + this.getsort();
103 }, 171 },
104 methods: { 172 methods: {
  173 + save(item) {
  174 + this.images = item.images_arr;
  175 + if (this.images.length == 0) {
  176 + this.nophoto = true;
  177 + } else {
  178 + this.index = 0;
  179 + this.show = true;
  180 + }
  181 + },
  182 + previewimg(index, indexk) {
  183 + console.log(index, indexk);
  184 + this.index = indexk;
  185 + this.images = this.sortlist[index].images_arr;
  186 + this.show = true;
  187 + this.startPosition = indexk;
  188 + },
  189 + nophotoup() {
  190 + this.nophoto = false;
  191 + },
  192 + // 图片预览
  193 + onChange(index) {
  194 + this.index = index;
  195 + },
  196 + onCopy(e) {
  197 + Toast("复制成功");
  198 + },
105 onLoad() { 199 onLoad() {
106 let that = this; 200 let that = this;
  201 + console.log(888);
  202 + // if (that.page = 1) {
  203 + // that.loading = false
  204 + // that.finished = false
  205 + // }
107 // 异步更新数据 206 // 异步更新数据
108 // setTimeout 仅做示例,真实场景中一般为 ajax 请求 207 // setTimeout 仅做示例,真实场景中一般为 ajax 请求
109 setTimeout(() => { 208 setTimeout(() => {
@@ -113,7 +212,7 @@ export default { @@ -113,7 +212,7 @@ export default {
113 let newpage = that.page; 212 let newpage = that.page;
114 newpage++; 213 newpage++;
115 that.page = newpage; 214 that.page = newpage;
116 - that.getsocidtylist() 215 + that.getsocidtylist();
117 // 加载状态结束 216 // 加载状态结束
118 that.loading = false; 217 that.loading = false;
119 // 数据全部加载完成 218 // 数据全部加载完成
@@ -122,19 +221,89 @@ export default { @@ -122,19 +221,89 @@ export default {
122 } 221 }
123 }, 1000); 222 }, 1000);
124 }, 223 },
  224 + // 收藏
  225 + collect(index, item) {
  226 + let that = this;
  227 + var url = "/api/user/favorite";
  228 + let param = {
  229 + type: 3,
  230 + favorite_id: item.id
  231 + };
  232 +
  233 + that.$axios
  234 + .post(url, param)
  235 + .then(function(res) {
  236 + console.log(res);
  237 + if (item.is_favorite == 0) {
  238 + item.is_favorite = 1;
  239 + that.sortlist[index].is_favorite = 1;
  240 + that.sortlist[index].favorite_count =
  241 + that.sortlist[index].favorite_count + 1;
  242 + Toast("收藏成功");
  243 + } else if (item.is_favorite == 1) {
  244 + item.is_favorite = 1;
  245 + Toast("取消收藏成功");
  246 + that.sortlist[index].is_favorite = 0;
  247 + that.sortlist[index].favorite_count =
  248 + that.sortlist[index].favorite_count - 1;
  249 + }
  250 + that.sortlist = that.sortlist;
  251 + that.$forceUpdate();
  252 + })
  253 + .catch(function(err) {
  254 + console.log(err);
  255 + });
  256 + },
  257 +
  258 + zanclick(index, item) {
  259 + let that = this;
  260 + console.log(item.id);
  261 + var url = "/api/user/good";
  262 + let param = {
  263 + type: 1,
  264 + good_id: item.id
  265 + };
  266 +
  267 + that.$axios
  268 + .post(url, param)
  269 + .then(function(res) {
  270 + console.log(res);
  271 + if (item.is_good == 0) {
  272 + item.is_good = 1;
  273 + that.sortlist[index].is_good = 1;
  274 + that.sortlist[index].good_count =
  275 + that.sortlist[index].good_count + 1;
  276 + Toast("点赞成功");
  277 + } else if (item.is_good == 1) {
  278 + item.is_good = 1;
  279 + Toast("取消点赞成功");
  280 + that.sortlist[index].is_good = 0;
  281 + that.sortlist[index].good_count =
  282 + that.sortlist[index].good_count - 1;
  283 + }
  284 + that.sortlist = that.sortlist;
  285 + that.$forceUpdate();
  286 + })
  287 + .catch(function(err) {
  288 + console.log(err);
  289 + });
  290 + },
  291 +
  292 + // 复制文本
  293 + copytext() {},
125 294
126 selectnav(id, index) { 295 selectnav(id, index) {
127 let that = this; 296 let that = this;
128 297
129 this.selnav = index; 298 this.selnav = index;
130 - this.sort_id = id 299 + this.sort_id = id;
131 that.page = 1; 300 that.page = 1;
132 that.sortlist = []; 301 that.sortlist = [];
133 - that.getsocidtylist() 302 + that.getsocidtylist();
134 }, 303 },
135 publish() { 304 publish() {
136 this.$router.push({ 305 this.$router.push({
137 - path: "/publish", 306 + path: "/publish"
138 // query: { testId: item.test_student_id } 307 // query: { testId: item.test_student_id }
139 }); 308 });
140 }, 309 },
@@ -142,19 +311,17 @@ export default { @@ -142,19 +311,17 @@ export default {
142 getsort() { 311 getsort() {
143 let that = this; 312 let that = this;
144 var url = "/api/social/sort"; 313 var url = "/api/social/sort";
145 - let param = {  
146 -  
147 - }; 314 + let param = {};
148 315
149 that.$axios 316 that.$axios
150 .post(url, param) 317 .post(url, param)
151 - .then(function (res) { 318 + .then(function(res) {
152 console.log(res); 319 console.log(res);
153 - that.navarr = res.data  
154 - that.sort_id = res.data[0].id  
155 - 320 + that.navarr = res.data;
  321 + that.sort_id = res.data[0].id;
  322 + that.getsocidtylist();
156 }) 323 })
157 - .catch(function (err) { 324 + .catch(function(err) {
158 console.log(err); 325 console.log(err);
159 }); 326 });
160 }, 327 },
@@ -169,14 +336,13 @@ export default { @@ -169,14 +336,13 @@ export default {
169 336
170 that.$axios 337 that.$axios
171 .post(url, param) 338 .post(url, param)
172 - .then(function (res) { 339 + .then(function(res) {
173 console.log(res); 340 console.log(res);
174 - that.sortlist = that.sortlist.concat(res.data.social) 341 + that.sortlist = that.sortlist.concat(res.data.social);
175 that.this_page = res.data.this_page; 342 that.this_page = res.data.this_page;
176 - that.total_page = res.data.total_page  
177 - 343 + that.total_page = res.data.total_page;
178 }) 344 })
179 - .catch(function (err) { 345 + .catch(function(err) {
180 console.log(err); 346 console.log(err);
181 }); 347 });
182 } 348 }
@@ -14,11 +14,17 @@ import axios from "./utils/common.js"; @@ -14,11 +14,17 @@ import axios from "./utils/common.js";
14 if (sessionStorage.getItem("token")) { 14 if (sessionStorage.getItem("token")) {
15 axios.defaults.headers.common["token"] = sessionStorage.getItem("token"); 15 axios.defaults.headers.common["token"] = sessionStorage.getItem("token");
16 } 16 }
  17 +import uploadFile from "./utils/common.js";
  18 +Vue.prototype.$uploadFile = uploadFile;
17 19
18 Vue.prototype.$axios = axios; 20 Vue.prototype.$axios = axios;
19 21
20 sessionStorage.setItem("token", "89cf0730-59e2-4627-baa3-a4451454794b"); 22 sessionStorage.setItem("token", "89cf0730-59e2-4627-baa3-a4451454794b");
21 23
  24 +import VueClipboard from "vue-clipboard2";
  25 +
  26 +Vue.use(VueClipboard);
  27 +
22 // router.beforeEach((to, from, next) => { 28 // router.beforeEach((to, from, next) => {
23 // const token = sessionStorage.getItem("token"); 29 // const token = sessionStorage.getItem("token");
24 // console.log("我是token", token); 30 // console.log("我是token", token);
@@ -55,6 +55,10 @@ @@ -55,6 +55,10 @@
55 border-radius: 50%; 55 border-radius: 50%;
56 } 56 }
57 57
  58 +.personimg img {
  59 + border-radius: 50%;
  60 +}
  61 +
58 .personname { 62 .personname {
59 color: #02170b; 63 color: #02170b;
60 font-size: 0.28rem; 64 font-size: 0.28rem;
@@ -105,6 +109,11 @@ @@ -105,6 +109,11 @@
105 font-size: 0.16rem; 109 font-size: 0.16rem;
106 line-height: 0.44rem; 110 line-height: 0.44rem;
107 margin-top: 0.32rem; 111 margin-top: 0.32rem;
  112 + margin-right: 0.2rem;
  113 +}
  114 +
  115 +.jianzhengtui {
  116 + flex-wrap: wrap;
108 } 117 }
109 118
110 .jianzhengleft { 119 .jianzhengleft {
@@ -139,7 +148,7 @@ @@ -139,7 +148,7 @@
139 } 148 }
140 149
141 .dianitem { 150 .dianitem {
142 - margin-right: 0.58rem; 151 + margin-right: 0.38rem;
143 } 152 }
144 153
145 .dainzan { 154 .dainzan {
@@ -184,7 +193,7 @@ @@ -184,7 +193,7 @@
184 /* 发布 */ 193 /* 发布 */
185 194
186 .publishitem { 195 .publishitem {
187 - padding: 0.26rem; 196 + padding: 0.26rem 0;
188 box-sizing: border-box; 197 box-sizing: border-box;
189 border-bottom: 1px solid #eee; 198 border-bottom: 1px solid #eee;
190 } 199 }
@@ -205,13 +214,13 @@ @@ -205,13 +214,13 @@
205 .kindname { 214 .kindname {
206 color: #999999; 215 color: #999999;
207 font-size: 0.28rem; 216 font-size: 0.28rem;
208 - margin-left: 0.32rem; 217 + /* margin-left: 0.32rem; */
209 } 218 }
210 219
211 .enterkind { 220 .enterkind {
212 width: 100%; 221 width: 100%;
213 height: 5rem; 222 height: 5rem;
214 - padding: 0.18rem 0.32rem; 223 + padding: 0.18rem 0;
215 color: #999999; 224 color: #999999;
216 font-size: 0.28rem; 225 font-size: 0.28rem;
217 box-sizing: border-box; 226 box-sizing: border-box;
@@ -23,4 +23,23 @@ Axios.interceptors.response.use( @@ -23,4 +23,23 @@ Axios.interceptors.response.use(
23 } 23 }
24 ); 24 );
25 25
26 -export default Axios;  
  26 +export default Axios;
  27 +export function uploadFile(Url, data) {
  28 + //上传图片的方法
  29 + return new Promise((resolve, reject) => {
  30 + let instance = axios.create({
  31 + baseURL: "http://tangyuanji.t.brotop.cn/api/",
  32 + headers: {
  33 + "Content-Type": "multipart/form-data"
  34 + }
  35 + });
  36 + instance
  37 + .post(Url, data)
  38 + .then(res => {
  39 + resolve(res.data.data);
  40 + })
  41 + .catch(error => {
  42 + reject(error.data);
  43 + });
  44 + });
  45 +}