articleItem.vue 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. <template>
  2. <div class="micro-home-article">
  3. <div class="top-author-info" v-if="articleData.has_one_stick_user">
  4. <img @click.stop="toUrl('microhomepage',{},{micuid: articleData.has_one_stick_user.uid})" class="avatar finger-point" :src="articleData.has_one_stick_user.avatar" alt="" />
  5. <div style="flex: 1">
  6. <p @click.stop="toUrl('microhomepage',{},{micuid: articleData.has_one_stick_user.uid})" class="author-name overflow-hide finger-point">{{ articleData.has_one_stick_user.nickname }}</p>
  7. <p class="create-time">{{articleData.created_at}}</p>
  8. </div>
  9. <template>
  10. <div class="tag is_top" v-if="articleData.is_top == 1">置顶</div>
  11. <div class="tag is_recommend" v-if="articleData.is_recommend == 1">推荐</div>
  12. <div v-if="articleData.is_own" class="edit-box">
  13. <i @click.stop="toEdit" class="iconfont icon-fontclass-bianji"></i>
  14. <i @click.stop="deleteBtn" class="iconfont icon-fontclass-shanchu"></i>
  15. </div>
  16. <div v-else @click.stop="attentionBtn" class="finger-point" :class="[articleData.is_follow ? 'not-follow' : 'follow-btn']" @click="articleData.is_follow = !articleData.is_follow">
  17. <span v-if="articleData.is_follow">已关注</span>
  18. <span v-else><i class="el-icon-plus"></i> 关注</span>
  19. </div>
  20. <div v-if="is_manager" class="edit-box">
  21. <el-popover trigger="click" popper-class="share-popover">
  22. <div class="popover-box">
  23. <p class="more-box finger-point" @click.stop="adminBtn(1)">{{articleData.is_recommend == 1 ? '取消推荐':'推荐'}}</p>
  24. <p class="more-box finger-point" @click.stop="adminBtn(2)">{{articleData.is_top == 1 ?'取消置顶':'置顶'}}</p>
  25. <p class="more-box finger-point" v-if="!articleData.is_own" @click.stop="deleteBtn">删除</p>
  26. </div>
  27. <span class="finger-point" ref="popoverBox" slot="reference"><i class="iconfont icon-zb_all_more"></i></span>
  28. </el-popover>
  29. </div>
  30. </template>
  31. </div>
  32. <div class="article-title finger-point" @click.stop="getMicroDetails(articleData.id)">{{articleData.title}}
  33. <span class="watch-num">
  34. <i class="iconfont icon-fontclass-yulan"></i>
  35. {{articleData.browse_num}}
  36. </span>
  37. </div>
  38. <!--<div class="article-content text-overflow-3">-->
  39. <!--{{articleData.contents}} <span class="finger-point" style="color: var(&#45;&#45;color);">阅读全文</span>-->
  40. <!--</div>-->
  41. <div :class="showTotal ? 'total-introduce' : 'detailed-introduce'" @click.stop="getMicroDetails(articleData.id)">
  42. <div class="intro-content cursor-default" ref="desc">
  43. <div class="merchant-desc" v-if="articleData.contents" :style="{width: is_detail?'825px':''}">
  44. <template v-if="articleData.contents.indexOf('micro-panel-body') > -1 || articleData.contents.indexOf('</p>') > -1">
  45. <!--判断是否富文本-->
  46. <p v-html="articleData.contents"></p>
  47. </template>
  48. <template v-else>
  49. <p v-for="(_item, i) in articleData.contents.split('\n')" :key="i" v-html="checkoutURL(_item)"></p>
  50. </template>
  51. <!--{{checkoutURL(articleData.contents)}}-->
  52. </div>
  53. <div class="unfold finger-point" @click.stop="showTotalIntro" v-if="showExchangeButton">
  54. <p>{{exchangeButton ? '展开' : '收起'}}</p>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="album" v-if="articleData.has_many_image">
  59. <template v-for="(item, index) in articleData.has_many_image">
  60. <div class="img-wrap-box" v-if="index <= 8" :key="item.id">
  61. <el-image
  62. :src="item.url" alt="" class="img" fit="contain"
  63. @click.stop="toShowImgViewer(index)"
  64. ></el-image>
  65. <div
  66. v-if="(articleData.has_many_image.length > 9) && (index === 8)"
  67. class="more-img-mask finger-point" @click.stop="toShowImgViewer(8)"
  68. >+{{articleData.has_many_image.length - 9}}</div>
  69. </div>
  70. </template>
  71. </div>
  72. <el-image-viewer
  73. v-if="showViewer"
  74. :initialIndex="initialIndex"
  75. @onClose="showViewer = false"
  76. :url-list="handleImage(articleData.has_many_image)"/>
  77. <div class="address" v-if="articleData.address">
  78. <i class="iconfont icon-fontclass-dizhi"></i>
  79. <span>{{articleData.address}}</span>
  80. </div>
  81. <div class="bottom-opts">
  82. <!-- 评论 -->
  83. <span class="finger-point" @click="getStickComment"><i class="iconfont icon-fontclass-pinglun2"></i>{{articleData.comments_num}}</span>
  84. <!-- 点赞 -->
  85. <span @click="isPraiseBtn" :style="{color: articleData.is_praise?'#ec544a':''}" class="finger-point"><i class="iconfont icon-fontclass-tuijian"></i>{{ articleData.praise_num }}</span>
  86. <!-- 分享 -->
  87. <client-only>
  88. <el-popover trigger="click" popper-class="share-popover">
  89. <div class="popover">
  90. <p class="share-title">
  91. 微信【扫一扫】分享或者复制链接到第三方平台分享
  92. </p>
  93. <div class="flex" style="margin-top: 8px;">
  94. <canvas class="qrccode-canvas-code" :id="`qrccode-canvas-code${articleData.id}`"></canvas>
  95. <div class="share-code-link">
  96. <p style="color: #ec544a;font-size: 12px;">链接:</p>
  97. <div class="link-box"><input title="" readonly="true" type="text" class="link" v-model="current_url" /><span class="copy-btn" @click.stop="copyContent(current_url)">复制</span></div>
  98. </div>
  99. </div>
  100. </div>
  101. <span class="flex flex-a-c flex-j-c finger-point" @click="createQrc(fun.toRealURl(`microcommentdetails/${articleData.id}`))" slot="reference"><i class="iconfont icon-bc_share_card"></i>分享</span>
  102. </el-popover>
  103. </client-only>
  104. <!-- 赞赏 -->
  105. <span class="flex flex-a-c flex-j-c finger-point" v-if="reward_button == 0" @click="moneyShow(0)"><i class="iconfont icon-fontclass-shang"></i>赞赏</span>
  106. </div>
  107. <!-- 心愿商品 -->
  108. <div class="store-goods-box">
  109. <el-row v-if="articleData.wish_state == 1 && articleData.order_id != 0" style="border-bottom: 1px solid #DCDFE6;">
  110. <el-col :span="6">心愿商品</el-col>
  111. <el-col :span="18" class="fulfill-wish" >
  112. <span @click.stop="getOrderDetail(articleData.order_id)" class="finger-point">
  113. 帮Ta完成心愿
  114. <i class="iconfont icon-advertise-next"></i>
  115. </span>
  116. </el-col>
  117. </el-row>
  118. <el-row class="store-goods" v-if="articleData.has_one_store || articleData.has_one_goods">
  119. <el-col v-if="articleData.has_one_store" @click.native="gotoStore" :span="11" class="left-store flex finger-point">
  120. <img class="store-img" :src="articleData.has_one_store.arr.thumb" alt="" />
  121. <div>
  122. <p class="store-name overflow-hide">{{ articleData.has_one_store.arr.store_name }}</p>
  123. <p class="store-abbreviation overflow-hide">{{ articleData.has_one_store.arr.address }}</p>
  124. </div>
  125. </el-col>
  126. <el-col v-if="articleData.has_one_goods" @click.native="gotoGoods" :span="13" class="right-goods flex finger-point">
  127. <el-divider v-if="articleData.has_one_store" direction="vertical"></el-divider>
  128. <img class="goods-img" :src="articleData.has_one_goods.thumb" alt="" />
  129. <div>
  130. <p class="goods-name overflow-hide">{{ articleData.has_one_goods.title }}</p>
  131. <p>
  132. <span class="current-price">¥{{ articleData.has_one_goods.price }}</span>
  133. <span class="price">¥{{ articleData.has_one_goods.market_price }}</span>
  134. </p>
  135. </div>
  136. </el-col>
  137. </el-row>
  138. </div>
  139. <!-- 评论 -->
  140. <transition name="el-fade-in">
  141. <div v-if="showComment">
  142. <comment ref="commentBox" :is_detail="is_detail" :comments="showCommentData" :comment_open="comment_open" :showMore="showMore"
  143. @delReply="delReply" @praiseBtn="praiseBtn" @moneyShow=childMoneyShow @confirm="subMainBtn"
  144. @loadMore="loadMore"
  145. ></comment>
  146. </div>
  147. </transition>
  148. <!-- 赞赏弹框 -->
  149. <el-dialog title="赞赏" :visible.sync="rewardDialogVisible" center class="reward-dialog">
  150. <el-divider class="el-divider"></el-divider>
  151. <el-form>
  152. <el-form-item label="赞赏金额:" label-width="90px">
  153. <el-input v-model="rewardAmount" label="" placeholder="请输入赞赏金额">
  154. <template slot="append"><span>元</span></template>
  155. </el-input>
  156. </el-form-item>
  157. <el-form-item>
  158. <el-radio-group v-model="rewardAmount" @change="changeRadio">
  159. <el-radio :label="item" border v-for="(item) in radioMap" :key="item">¥{{item}}</el-radio>
  160. </el-radio-group>
  161. </el-form-item>
  162. </el-form>
  163. <div slot="footer" class="dialog-footer">
  164. <el-button @click="rewardDialogVisible = false">关闭</el-button>
  165. <el-button type="primary" @click="confirmRewardBtn">确 定 赞 赏</el-button>
  166. </div>
  167. </el-dialog>
  168. <!-- 订单详情 -->
  169. <el-dialog title="订单详情"
  170. :visible.sync="orderDialogVisible" center
  171. class="order-detail-dialog" width="70%"
  172. >
  173. <el-divider class="el-divider"></el-divider>
  174. <div class="order-apply">
  175. <div class="top-member-info flex flex-a-c" v-if="articleData.has_one_stick_user">
  176. <img class="member-avatar" :src="articleData.has_one_stick_user.avatar" alt="">
  177. <span class="member-ncikname overflow-hide">{{ articleData.has_one_stick_user.nickname }}</span>
  178. <span> 请您帮忙代付一笔订单</span>
  179. </div>
  180. <p class="order-tip overflow-hide">好友代付说明:代付前请和好友确认核实订单详情,以免下错订单</p>
  181. </div>
  182. <el-table :data="orderData.has_many_order_goods" class="order-table ">
  183. <el-table-column prop="goods" label="商品" width="500">
  184. <template slot-scope="scope">
  185. <div class="flex flex-a-c">
  186. <img class="goods-img" :src="scope.row.thumb" alt="">
  187. <div class="goods-name text-overflow-2">{{scope.row.title}}</div>
  188. </div>
  189. </template>
  190. </el-table-column>
  191. <el-table-column prop="goods_option_title" label="规格"></el-table-column>
  192. <el-table-column prop="price" label="单价"></el-table-column>
  193. <el-table-column prop="total" label="数量"></el-table-column>
  194. </el-table>
  195. <div class="pay-amount" v-if="money">
  196. 实付金额:<span class="value">¥{{money}}</span>
  197. </div>
  198. <div slot="footer" class="dialog-footer">
  199. <el-button @click="orderDialogVisible = false">关闭</el-button>
  200. <el-button type="primary" @click="toPay">去 支 付</el-button>
  201. </div>
  202. </el-dialog>
  203. <payBox ref="payBox" :orderPayId="parseInt(order_ids)" :pay_way="pay_way" :pay_sn="pay_sn" :order_pay_id="order_pay_id" :money="money" :from="from" :noJump="true" :rewardTypes="rewardTypes" :trick_id="trick_id" @paySuccess="paySuccess"></payBox>
  204. <!--from=course-->
  205. </div>
  206. </template>
  207. <script>
  208. import QRCode from "qrcode";
  209. import Comment from "~/components/microHome/comment";
  210. import payBox from "~/components/default/payBox";
  211. import ElImageViewer from '~/components/default/image-viewer'
  212. var canvas = "";
  213. export default {
  214. props: {
  215. articleData: {
  216. type: Object,
  217. default: ()=>{},
  218. },
  219. is_manager: {}, // 是否显示修改图标
  220. reward_button: {},
  221. comment_open: {},
  222. is_detail: {}
  223. },
  224. data() {
  225. return {
  226. current_url: "",
  227. rewardDialogVisible: false, // 打赏
  228. rewardTypes: 0, //打赏类型。0:帖子打赏||1:评论打赏
  229. trick_id: 0,
  230. radioMap: ["1", "5", "10", "20", "30", "50", "100", "200"],
  231. rewardAmount: '',
  232. reward_commend_id: 0, //打赏评论id
  233. showViewer: false,
  234. initialIndex: 0,
  235. // 是否展示所有文本内容
  236. showTotal: true,
  237. // 显示展开还是收起
  238. exchangeButton: true,
  239. // 是否显示展开收起按钮
  240. showExchangeButton: false,
  241. rem: '',
  242. showComment: false,
  243. page: 1,
  244. comment_total: 0,
  245. showMore: false,
  246. commentData: [],
  247. showCommentData: [],
  248. orderDialogVisible: false, // 订单
  249. order_ids: "",
  250. orderData: {},
  251. pay_way: [],
  252. pay_sn: "",
  253. order_pay_id: 0,
  254. money: "",
  255. from: 'pay',
  256. };
  257. },
  258. mounted(){
  259. this.$nextTick( ()=> {
  260. if(this.is_detail == 1) {
  261. this.getStickComment();
  262. return
  263. }
  264. // 判断介绍是否超过四行
  265. let rem = parseFloat(this.getRem());
  266. // console.log('watch 中的rem', rem);
  267. if (!this.$refs.desc) {
  268. console.log('desc null');
  269. return;
  270. }
  271. let descHeight = window.getComputedStyle(this.$refs.desc).height.replace('px', '');
  272. if (descHeight > 1.25 * rem) {
  273. // console.log('descHeight:' + descHeight);
  274. // console.log('如果 descHeight 超过' + (1.25 * rem) + '就要显示展开按钮');
  275. // 显示展开收起按钮
  276. this.showExchangeButton = true;
  277. this.exchangeButton = true;
  278. // 不是显示所有
  279. this.showTotal = false;
  280. } else {
  281. // 不显示展开收起按钮
  282. this.showExchangeButton = false;
  283. // 没有超过四行就显示所有
  284. this.showTotal = true;
  285. }
  286. })
  287. },
  288. methods: {
  289. checkoutURL(str){
  290. // 要以http 开头 防止图片src开头
  291. let reg = /^(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-|#|;|%)+)/g;
  292. str = str.replace(reg, (website)=>{
  293. return "<span onclick='event.stopPropagation ? event.stopPropagation() : (event.cancelBubble = true); // 阻止事件冒泡'><a class='article-link-color' href='" + website +"' target='_blank'>" + website + "</a></span>";
  294. });
  295. return str;
  296. },
  297. toShowImgViewer(index) {
  298. this.initialIndex = index;
  299. this.showViewer = true;
  300. },
  301. showTotalIntro () {
  302. this.showTotal = !this.showTotal;
  303. this.exchangeButton = !this.exchangeButton;
  304. },
  305. getRem () {
  306. const defaultRem = 16;
  307. let winWidth = window.innerWidth;
  308. // console.log('winWidth:' + winWidth);
  309. let rem = winWidth / 375 * defaultRem;
  310. return rem;
  311. },
  312. handleImage(imgList) {
  313. let arr = [];
  314. imgList.map(item=> {
  315. arr.push(item.url);
  316. });
  317. return arr;
  318. },
  319. gotoStore() {
  320. window.open(this.fun.toRealURl(`o2o/home/homeseller/${this.articleData.has_one_store.arr.id}`));
  321. },
  322. gotoGoods() {
  323. // this.$router.push(this.fun.getUrl("goods-id", { id: _id }));
  324. window.open(this.fun.getSiteRoot() + "/plugins/shop_server/goods/"+ this.articleData.has_one_goods.id +"?i=" +this.fun.getKeyByI(), "_blank");
  325. },
  326. toEdit() {
  327. this.$router.push(this.fun.getUrl("microRelease",{},{tid: this.articleData.id}));
  328. },
  329. //获取订单详情
  330. getOrderDetail(oid) {
  331. this.order_ids = oid;
  332. this.money = "";
  333. this.fun.$get("order.another-pay-detail", {
  334. order_id: oid,
  335. pid: this.articleData.has_one_stick_user.uid
  336. },'load').then(response => {
  337. if (response.result == 1) {
  338. this.getPayerInfo(oid);
  339. this.orderData = response.data[0] || {};
  340. this.order_sn = response.data[0].order_sn;
  341. this.orderDialogVisible = true;
  342. } else {
  343. this.$message.error(response.msg);
  344. }
  345. });
  346. },
  347. //获取代付会员信息和支付信息
  348. getPayerInfo(oid) {
  349. this.fun.$get("order.merge-pay.anotherPayOrder", {
  350. order_ids: oid,
  351. mid: this.$route.query.mid,
  352. pid: this.articleData.has_one_stick_user.uid
  353. },'load').then(response => {
  354. if (response.result == 1) {
  355. let arr = response.data.buttons;
  356. if (response.data.buttons && !(response.data.buttons instanceof Array)) {
  357. arr = Object.values(response.data.buttons);
  358. }
  359. this.pay_way = arr;
  360. this.pay_sn = response.data.order_pay.pay_sn;
  361. this.order_pay_id = response.data.order_pay.id;
  362. this.money = String(response.data.order_pay.amount);
  363. } else if (response.result == 0) {
  364. this.$message.error(response.msg);
  365. }
  366. });
  367. },
  368. toPay() {
  369. this.orderDialogVisible = false;
  370. this.from = 'pay';
  371. this.$refs.payBox.showPay();
  372. },
  373. deleteBtn() {
  374. this.$confirm('确认删除该帖子吗?', '提示', {
  375. confirmButtonText: '确定',
  376. cancelButtonText: '取消',
  377. type: 'warning'
  378. }).then(() => {
  379. this.fun.$post("plugin.micro-communities.api.trick.delTrick", {
  380. tid: this.articleData.id
  381. }).then(response => {
  382. if (response.result == 1) {
  383. this.$message.success(response.msg);
  384. this.$emit('updateArticles')
  385. // this.$router.push(this.fun.getUrl("microIndex"));
  386. } else {
  387. this.$message.error(response.msg);
  388. }
  389. });
  390. }).catch(() => {});
  391. },
  392. adminBtn(typenum) {
  393. let dataJson = {
  394. tid: this.articleData.id
  395. };
  396. if (typenum == 1) {
  397. dataJson.state = this.articleData.is_recommend == 1 ? 0 : 1;
  398. dataJson.operation = 1;
  399. } else if (typenum == 2) {
  400. dataJson.state = this.articleData.is_top == 1 ? 0 : 1;
  401. dataJson.operation = 2;
  402. }
  403. this.fun.$post("plugin.micro-communities.api.trick.changeOperation", dataJson,'load').then(response => {
  404. if (response.result == 1) {
  405. if (typenum == 1) {
  406. this.articleData.is_recommend = this.articleData.is_recommend == 1 ? 0 : 1;
  407. } else if (typenum == 2) {
  408. this.articleData.is_top = this.articleData.is_top == 1 ? 0 : 1;
  409. }
  410. this.$refs.popoverBox.click();
  411. // this.$emit('updateArticles');
  412. this.$message.success(response.msg);
  413. } else {
  414. this.$message.error(response.msg);
  415. }
  416. });
  417. },
  418. // 关注
  419. attentionBtn() {
  420. if (this.articleData.is_follow) {
  421. this.cancelAttention();
  422. } else {
  423. this.addAttention();
  424. }
  425. },
  426. cancelAttention() {
  427. let dataJson = {
  428. uid: this.articleData.user_id
  429. };
  430. this.fun.$post("plugin.micro-communities.api.user.delFollow", dataJson).then(response => {
  431. if (response.result == 1) {
  432. this.$set(this.articleData, "is_follow", false); //动态添加
  433. this.$message.success(response.msg);
  434. } else {
  435. this.$message.error(response.msg);
  436. }
  437. });
  438. },
  439. addAttention() {
  440. let dataJson = {
  441. user_id: this.articleData.user_id
  442. };
  443. this.fun.$post("plugin.micro-communities.api.user.addFollow", dataJson).then(response => {
  444. if (response.result == 1) {
  445. this.$set(this.articleData, "is_follow", true); //动态添加
  446. this.$message.success(response.msg);
  447. } else {
  448. this.$message.error(response.msg);
  449. }
  450. });
  451. },
  452. praiseBtn(data) {
  453. let {host_comment_id, second_comment_id, index, chilindex, is_praise} = data;
  454. // console.log("5555", data);
  455. if (is_praise == 1) {
  456. this.$message.error("你已赞过该贴");
  457. return;
  458. }
  459. this.getPraiseData(host_comment_id, second_comment_id, index, chilindex, "");
  460. },
  461. isPraiseBtn() {
  462. if (this.articleData.is_praise == 1) {
  463. this.$message.error("你已赞过该贴");
  464. return;
  465. }
  466. this.getPraiseData("", "", "", "", "main");
  467. },
  468. getPraiseData(host_comment_id, second_comment_id, index, chilindex, type) {
  469. let dataJson = {};
  470. if (!host_comment_id) {
  471. dataJson.tid = this.articleData.id;
  472. }
  473. if (host_comment_id && second_comment_id) {
  474. dataJson.comment_id = second_comment_id;
  475. } else {
  476. dataJson.comment_id = host_comment_id;
  477. }
  478. this.fun.$post("plugin.micro-communities.api.trick.givePraise", dataJson, 'load').then(response => {
  479. if (response.result == 1) {
  480. if ("main" == type) {
  481. this.$set(this.articleData, "praise_num", this.articleData.praise_num ? this.articleData.praise_num + 1 : 1); //动态添加
  482. } else {
  483. // 评论点赞
  484. if (host_comment_id && second_comment_id) {
  485. let childData = this.commentData[index].child[chilindex];
  486. this.$set(childData, "is_praise", 1); //动态添加
  487. this.$set(childData, "praise_num", childData.praise_num ? childData.praise_num + 1 : 1); //动态添加
  488. } else {
  489. let commentData = this.commentData[index];
  490. this.$set(commentData, "is_praise", 1); //动态添加
  491. this.$set(commentData, "praise_num", commentData.praise_num ? commentData.praise_num + 1 : 1); //动态添加
  492. }
  493. this.showCommentData = this.commentData;
  494. }
  495. this.$message.success(response.msg);
  496. } else {
  497. this.$message.error(response.msg);
  498. }
  499. });
  500. },
  501. // 评论
  502. delReply(data) {
  503. this.fun.$post("plugin.micro-communities.api.trick.delComment", {commend_id: data.id}).then(response => {
  504. if (response.result == 1) {
  505. this.getStickComment('noClick');
  506. this.$message.success(response.msg);
  507. } else {
  508. this.$message.error(response.msg);
  509. }
  510. });
  511. },
  512. subMainBtn(data) {
  513. if (data) {
  514. this.postReplyComments(data);
  515. }
  516. },
  517. postReplyComments(e) {
  518. let dataJson = {
  519. image: e.image,
  520. content: e.content
  521. };
  522. dataJson.tid = this.articleData.id;
  523. if (e.options_type === "reply") {
  524. dataJson.host_comment_id = e.host_comment_id;
  525. }else if (e.options_type === "childReply") {
  526. dataJson.host_comment_id = e.host_comment_id;
  527. dataJson.second_comment_id = e.second_comment_id;
  528. }
  529. this.fun.$post("plugin.micro-communities.api.trick.comments", dataJson,'load').then(response => {
  530. if (response.result == 1) {
  531. this.articleData.comments_num += 1;
  532. this.getStickComment('noClick');
  533. this.$message.success(response.msg);
  534. } else {
  535. this.$message.error(response.msg);
  536. }
  537. });
  538. },
  539. getStickComment(flag) {
  540. if(flag !== 'noClick') {
  541. this.showComment = !this.showComment;
  542. }
  543. if(this.showComment) {
  544. if(this.articleData.comments_num <= 0) {
  545. if(this.is_detail == 1) {
  546. this.$nextTick(()=> {
  547. this.$refs.commentBox && this.$refs.commentBox.showCommentInput('','','noFocus');
  548. setTimeout(()=>{
  549. window.scrollTo(0,0)
  550. },200)
  551. })
  552. }
  553. return
  554. }
  555. this.page = 1;
  556. this.showMore = false;
  557. this.fun.$post("plugin.micro-communities.api.trick.getStickComment", {
  558. tid: this.articleData.id,
  559. page: this.page
  560. }, '...').then(response => {
  561. if (response.result == 1) {
  562. if(this.is_detail == 1) {
  563. this.$nextTick(()=> {
  564. this.$refs.commentBox && this.$refs.commentBox.showCommentInput('','','noFocus');
  565. setTimeout(()=>{
  566. window.scrollTo(0,0)
  567. },200)
  568. })
  569. }
  570. this.comment_total = response.data.total || 0;
  571. this.commentData = response.data.data || [];
  572. this.showCommentData = this.commentData.slice(0,3);
  573. if(this.showCommentData.length < this.comment_total) {
  574. this.showMore = true;
  575. }
  576. } else {
  577. this.$message.error(response.msg);
  578. }
  579. });
  580. }
  581. },
  582. loadMore(position) {
  583. if(this.showCommentData.length < this.commentData.length) {
  584. this.showCommentData = this.commentData;
  585. if(position){
  586. this.$refs.commentBox.move_comment_handle(true)
  587. }
  588. if(this.showCommentData.length < this.comment_total) {
  589. this.showMore = true;
  590. }else {
  591. this.showMore = false;
  592. }
  593. return;
  594. }
  595. this.page = this.page + 1;
  596. this.showMore = false;
  597. this.fun.$post("plugin.micro-communities.api.trick.getStickComment", {
  598. tid: this.articleData.id,
  599. page: this.page
  600. }, "加载中...").then(
  601. (response)=> {
  602. if (response.result === 1) {
  603. var myData = response.data.data;
  604. this.commentData = this.commentData.concat(myData);
  605. this.showCommentData = this.commentData;
  606. if(this.showCommentData.length < this.comment_total) {
  607. this.showMore = true;
  608. }
  609. } else {
  610. this.page = this.page - 1;
  611. }
  612. }
  613. );
  614. },
  615. childMoneyShow(data) {
  616. this.moneyShow(1, data.id, data.uname);
  617. },
  618. moneyShow(tag, cid, uname) {
  619. this.rewardTypes = tag;
  620. this.rewardAmount = '';
  621. this.reward_commend_id = cid;
  622. if (this.rewardTypes == 0) {
  623. this.trick_id = this.articleData.id;
  624. this.pay_sn = this.articleData.has_one_stick_user.nickname;
  625. }else {
  626. this.trick_id = this.reward_commend_id;
  627. this.pay_sn = uname || this.articleData.has_one_stick_user.nickname;
  628. }
  629. this.rewardDialogVisible = true;
  630. },
  631. changeRadio (val) {
  632. this.rewardAmount = val;
  633. },
  634. confirmRewardBtn() {
  635. if (this.fun.isTextEmpty(this.rewardAmount)) {
  636. this.$message.error("请输入或选择打赏金额");
  637. return;
  638. }
  639. if (Number(this.rewardAmount) <= 0) {
  640. this.$message.error("打赏金额必须大于0");
  641. return;
  642. }
  643. this.getPayData();
  644. },
  645. //获取支付类型参数
  646. getPayData() {
  647. this.fun.$get("plugin.micro-communities.api.reward-log.get-payment-buttons", {}, "")
  648. .then(response => {
  649. if (response.result == 1) {
  650. this.rewardDialogVisible = false;
  651. this.pay_way = response.data.buttons || [];
  652. this.from = 'micro';
  653. this.money = String(this.rewardAmount);
  654. this.$refs.payBox.showPay();
  655. }else {
  656. this.$message.error(response.msg)
  657. }
  658. });
  659. },
  660. paySuccess() {
  661. // 支付成功后
  662. this.$emit('updateArticles');
  663. },
  664. copyContent(text) {
  665. // 不要格式化
  666. let copy = `标题:${this.articleData.title}
  667. 链接:${text}`;
  668. this.fun.copyContent(copy);
  669. this.$message.success('复制成功');
  670. },
  671. createQrc(url) {
  672. this.current_url = this.fun.toPCRealURl(`microcommentdetails/${this.articleData.id}`);
  673. setTimeout(()=>{
  674. this.$nextTick(function () {
  675. // DOM操作
  676. canvas = document.getElementById(`qrccode-canvas-code${this.articleData.id}`);
  677. QRCode.toCanvas(canvas, url, error => {
  678. if (error) {
  679. console.log(error);
  680. }
  681. });
  682. });
  683. },200);
  684. },
  685. getMicroDetails(stickid) {
  686. if(this.is_detail == 1) {
  687. return;
  688. }
  689. if(this.fun.getSiteRoot() == "http://localhost:82") {
  690. this.toUrl('microcommentdetails-tid',{tid: stickid})
  691. }else {
  692. window.open(this.fun.getSiteRoot() + `/plugins/shop_server/microcommentdetails/${stickid}?i=` +this.fun.getKeyByI(), "_blank");
  693. }
  694. },
  695. toUrl(url, params, query) {
  696. this.$router.push(this.fun.getUrl(url, params, query));
  697. },
  698. },
  699. components: {
  700. Comment,
  701. payBox,
  702. ElImageViewer
  703. },
  704. };
  705. </script>
  706. <style>
  707. .article-link-color {
  708. color: #4094f5;
  709. }
  710. .article-link-color:hover {
  711. color: #3462b4;
  712. }
  713. </style>
  714. <style lang='scss' rel='stylesheet/scss' scoped>
  715. .qrccode-canvas-code {
  716. width: 65px!important;
  717. height: 65px!important;
  718. margin-right: 10px;
  719. }
  720. .share-code-link {
  721. display: flex;
  722. flex-direction: column;
  723. justify-content: space-between;
  724. padding: 5px 0;
  725. }
  726. .link-box {
  727. margin-top: 5px;
  728. width: 230px;
  729. display: flex;
  730. border-radius: 4px;
  731. overflow: hidden;
  732. }
  733. .link {
  734. background-color: #ececec;
  735. overflow: hidden;
  736. flex: 1;
  737. word-break: keep-all;
  738. white-space: nowrap;
  739. padding: 3px 0 3px 5px;
  740. border: none;
  741. }
  742. .copy-btn {
  743. flex: 0 0 36px;
  744. font-size: 12px;
  745. text-align: center;
  746. background-color: #ec544a;
  747. color: #ffffff;
  748. border-radius: 4px;
  749. padding: 3px 5px;
  750. cursor: pointer;
  751. }
  752. .popover-box {
  753. display: flex;
  754. flex-direction: column;
  755. text-align: center;
  756. .more-box {
  757. padding: 6px;
  758. border-bottom: 1px solid #efefef;
  759. }
  760. .more-box:hover {
  761. color: #ec544a;
  762. }
  763. .more-box:last-child {
  764. border: none;
  765. }
  766. }
  767. .micro-home-article {
  768. $--color-primary: #409EFF;
  769. margin: 10px 0;
  770. width: 100%;
  771. padding: 14px 18px;
  772. border-radius: 4px;
  773. background-color: #ffffff;
  774. .top-author-info {
  775. display: flex;
  776. align-items: center;
  777. .avatar {
  778. width: 50px;
  779. height: 50px;
  780. margin-right: 10px;
  781. border-radius: 50%;
  782. background-color: #b3b3b3;
  783. }
  784. .author-name {
  785. width: 100px;
  786. font-size: 14px;
  787. font-weight: bold;
  788. color: #333333;
  789. }
  790. .create-time {
  791. font-size: 12px;
  792. color: #888888;
  793. margin-top: 5px;
  794. }
  795. .not-follow {
  796. width: 80px;
  797. line-height: 26px;
  798. color: #ffffff;
  799. border-radius: 16px;
  800. background-color: #cacaca;
  801. text-align: center;
  802. }
  803. .follow-btn {
  804. width: 80px;
  805. line-height: 26px;
  806. color: #2973fd;
  807. border-radius: 16px;
  808. border: solid 1px #2973fd;
  809. text-align: center;
  810. }
  811. .tag {
  812. background-color: #f0f6ff;
  813. border: 1px solid #2070f8;
  814. color: #2070f8;
  815. padding: 3px 10px;
  816. border-radius: 5px;
  817. margin: 0 5px;
  818. }
  819. .is_recommend {
  820. background-color: #fff4f4;
  821. border: 1px solid #f2534f;
  822. color: #f2534f;
  823. }
  824. .edit-box {
  825. color: #838382;
  826. font-size: 16px;
  827. .iconfont {
  828. cursor: pointer;
  829. font-size: 18px;
  830. margin-left: 20px;
  831. }
  832. .icon-zb_all_more {
  833. font-size: 22px;
  834. }
  835. }
  836. }
  837. .article-content, .album, .bottom-opts, .address, .store-goods-box {
  838. padding: 5px 50px;
  839. }
  840. .article-title {
  841. margin: 10px 10px 0 10px;
  842. font-size: 16px;
  843. font-weight: bold;
  844. .watch-num {
  845. font-size: 14px;
  846. font-weight: normal;
  847. margin-left: 8px;
  848. color: #6b6b6b;
  849. }
  850. }
  851. .article-content {
  852. font-size: 14px;
  853. padding: 0 50px;
  854. color: #4f4f4f;
  855. }
  856. .total-introduce {
  857. height: auto;
  858. overflow: hidden;
  859. font-size: 14px;
  860. color: #4f4f4f;
  861. .intro-content {
  862. margin: 10px;
  863. .merchant-desc {
  864. width: 100%;
  865. line-height: 21px;
  866. }
  867. }
  868. .unfold {
  869. display: block;
  870. z-index: 11;
  871. float: right;
  872. width: 40px;
  873. height: 21px;
  874. p {
  875. margin: 0;
  876. line-height: 21px;
  877. color: #7fbe87;
  878. }
  879. }
  880. }
  881. .detailed-introduce {
  882. font-size: 14px;
  883. color: #434343;
  884. position: relative;
  885. overflow: hidden;
  886. margin: 10px;
  887. .intro-content {
  888. // 最大高度设为3倍的行间距
  889. max-height: 63px;
  890. line-height: 21px;
  891. word-wrap: break-word;
  892. /*强制打散字符*/
  893. word-break: break-all;
  894. /*background: #ffffff;*/
  895. /*同背景色*/
  896. /*color: #ffffff;*/
  897. overflow: hidden;
  898. .merchant-desc {
  899. width: 100%;
  900. line-height: 21px;
  901. display: -webkit-box;
  902. -webkit-box-orient: vertical;
  903. overflow: hidden;
  904. height: 63px;
  905. /*截取行数*/
  906. -webkit-line-clamp: 3;
  907. text-overflow: ellipsis;
  908. -webkit-box-sizing: border-box;
  909. box-sizing: border-box;
  910. /*行首缩进字符数,值为[(截取行数-1)*尾部留空字符数]*/
  911. //text-indent: -12em;
  912. /*尾部留空字符数*/
  913. padding-right: 3em;
  914. }
  915. /*&:after,*/
  916. /*// 这是展开前实际显示的内容*/
  917. /*&:before {*/
  918. /*content: attr(title);*/
  919. /*position: absolute;*/
  920. /*left: 0;*/
  921. /*top: 0;*/
  922. /*width: 100%;*/
  923. /*color: #434343*/
  924. /*// overflow: hidden;*/
  925. /*}*/
  926. // 把最后最后一行自身的上面三行遮住
  927. /*&:before {*/
  928. /*display: block;*/
  929. /*overflow: hidden;*/
  930. /*z-index: 1;*/
  931. /*max-height: 42px;*/
  932. /*background: #ffffff;*/
  933. /*}*/
  934. /*&:after {*/
  935. /*display: -webkit-box;*/
  936. /*-webkit-box-orient: vertical;*/
  937. /*overflow: hidden;*/
  938. /*height: 63px;*/
  939. /*截取行数*/
  940. /*-webkit-line-clamp: 3;*/
  941. /*text-overflow: ellipsis;*/
  942. /*-webkit-box-sizing: border-box;*/
  943. /*box-sizing: border-box;*/
  944. /*行首缩进字符数,值为[(截取行数-1)*尾部留空字符数]*/
  945. //text-indent: -12em;
  946. /*尾部留空字符数*/
  947. /*padding-right: 4em;*/
  948. /*}*!*/
  949. .unfold {
  950. z-index: 11;
  951. width: 40px;
  952. height: 21px;
  953. outline: 0;
  954. position: absolute;
  955. right: 0;
  956. bottom: 0;
  957. p {
  958. margin: 0;
  959. line-height: 21px;
  960. color: #7fbe87;
  961. }
  962. }
  963. }
  964. }
  965. .album {
  966. display: grid;
  967. grid-template-columns: repeat(3, 190px);
  968. grid-gap: 10px;
  969. .img-wrap-box {
  970. width: 190px;
  971. height: 190px;
  972. position: relative;
  973. }
  974. .img {
  975. cursor: pointer;
  976. width: 100%;
  977. height: 100%;
  978. border-radius: 4px;
  979. }
  980. .more-img-mask {
  981. position: absolute;
  982. display: flex;
  983. align-items: center;
  984. justify-content: center;
  985. top: 0;
  986. left: 0;
  987. width: 100%;
  988. height: 100%;
  989. color: #ffffff;
  990. background-color: #161616;
  991. opacity: 0.5;
  992. }
  993. }
  994. .address {
  995. font-size: 12px;
  996. color: #ff8200;
  997. }
  998. .bottom-opts {
  999. display: flex;
  1000. justify-content: space-between;
  1001. margin: 20px 0;
  1002. .iconfont {
  1003. margin-right: 4px;
  1004. }
  1005. }
  1006. .store-goods-box {
  1007. .el-row {
  1008. padding: 10px;
  1009. background-color: #f3f3f3;
  1010. }
  1011. .fulfill-wish {
  1012. text-align: right;
  1013. color: #ec544a;
  1014. }
  1015. .left-store, .right-goods {
  1016. flex: 1;
  1017. font-size: 14px;
  1018. line-height: 22px;
  1019. .store-name, .goods-name, .store-abbreviation {
  1020. max-width: 150px;
  1021. }
  1022. .store-img, .goods-img {
  1023. width: 40px;
  1024. height: 40px;
  1025. margin-right: 8px;
  1026. border-radius: 4px;
  1027. }
  1028. .el-divider {
  1029. margin-right: 10px;
  1030. height: 40px;
  1031. }
  1032. }
  1033. .store-abbreviation {
  1034. font-size: 12px;
  1035. color: #737373;
  1036. }
  1037. .current-price {
  1038. font-size: 12px;
  1039. color: #ec544a;
  1040. }
  1041. .price {
  1042. margin-left: 15px;
  1043. font-size: 12px;
  1044. color: #737373;
  1045. text-decoration:line-through
  1046. }
  1047. }
  1048. :deep(.el-dialog) {
  1049. .el-divider {
  1050. margin: 0 0 24px 0;
  1051. }
  1052. }
  1053. :deep(.reward-dialog) {
  1054. .el-radio__inner {
  1055. display: none !important;
  1056. }
  1057. .el-radio-group {
  1058. padding: 0 20px;
  1059. display: grid;
  1060. grid-template-columns: repeat(4, 70px);
  1061. grid-gap: 15px 25px;
  1062. justify-content: center;
  1063. .el-radio {
  1064. text-align: center;
  1065. }
  1066. .is-bordered {
  1067. margin-left: 0;
  1068. margin-right: -10px;
  1069. }
  1070. .is-checked {
  1071. border: none;
  1072. background-color: #ec544a;
  1073. .el-radio__label {
  1074. color: #ffffff;
  1075. }
  1076. }
  1077. }
  1078. }
  1079. .order-detail-dialog {
  1080. .order-apply {
  1081. padding: 14px;
  1082. background-color: #f5f5f5;
  1083. border-radius: 2px;
  1084. .member-avatar {
  1085. width: 28px;
  1086. height: 28px;
  1087. border-radius: 50%;
  1088. }
  1089. .member-ncikname {
  1090. margin: 0 10px;
  1091. display: inline-block;
  1092. max-width: 150px;
  1093. }
  1094. .order-tip {
  1095. margin-top: 10px;
  1096. font-size: 12px;
  1097. color: #f11111;
  1098. }
  1099. }
  1100. .order-table {
  1101. .goods-img {
  1102. width: 60px;
  1103. height: 60px;
  1104. border-radius: 4px;
  1105. }
  1106. .goods-name {
  1107. margin-left: 10px;
  1108. max-width: 350px;
  1109. }
  1110. }
  1111. .pay-amount {
  1112. text-align: right;
  1113. padding: 20px 0;
  1114. font-size: 16px;
  1115. .value {
  1116. color: #f11111;
  1117. }
  1118. }
  1119. }
  1120. }
  1121. </style>