comment.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <template>
  2. <view class="content-box">
  3. <!-- <view class="info-box">
  4. <view class="img-container">
  5. <label for="img">添加评论</label>
  6. <view class="note-image-box">
  7. <view class="note-image-item" v-for="(item,index) in uploadList" :key="index">
  8. <view class="close-icon" @click="delPhoto(index)">
  9. <uni-icons type="closeempty" size="18" color="#fff"></uni-icons>
  10. </view>
  11. <view class="image-box" @click="showLarge(item)">
  12. <image :src="item" mode="aspectFill"></image>
  13. </view>
  14. </view>
  15. <view v-if="uploadList.length < 3" class="note-image-item" @click="getImage('album')">
  16. <view class="image-box">
  17. <uni-icons type="plusempty" size="50" color="#eee"></uni-icons>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </view> -->
  23. <view class="info-box">
  24. <view class="info-title-box">
  25. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  26. <text>添加评论</text>
  27. </view>
  28. <view class="info-value-box">
  29. <textarea type="text" class="textarea-box" v-model="contentDesc"></textarea>
  30. </view>
  31. </view>
  32. <view class="footer-box">
  33. <!-- <button type="primary" class="submit-bth" style="background-color: #aaaaaa;" @click="goStep()">清空</button> -->
  34. <button type="primary" class="submit-bth" style="background-color: #169bd5;" @click="goComment()">提交</button>
  35. </view>
  36. <!-- <view class="mask-share-box" v-if="isShowShare">
  37. <image src="/static/share-arrow.png" mode="aspectFit"></image>
  38. <view>点击右上角分享</view>
  39. <button @click="closeShare">关闭</button>
  40. </view> -->
  41. <!-- <share-modal @closeShare="closeShare" :isShowShare="isShowShareModal"></share-modal> -->
  42. </view>
  43. </template>
  44. <script>
  45. import md5 from "@/common/md5.js";
  46. import shareModal from '@/components/share-modal/share-modal.vue'
  47. // var graceChecker = require("../../../common/graceChecker.js");
  48. export default {
  49. components: {
  50. "share-modal": shareModal,
  51. },
  52. data() {
  53. return {
  54. globalUrl:getApp().globalData.shareUrl,
  55. branchId:'',
  56. activeId:'',
  57. recordId:'',
  58. recordObj:{},
  59. imgIdList: [],
  60. uploadList:[],
  61. contentDesc:'',
  62. contentLink:'',
  63. type:'add',
  64. isShowShareModal:false,
  65. }
  66. },
  67. onLoad(option) {
  68. console.log(option)
  69. this.branchId = option.bId;
  70. this.activeId = option.aId;
  71. this.type = option.types;
  72. if(option.types === 'edit'){
  73. this.getInfos(option.id)
  74. }
  75. },
  76. onShow() {
  77. },
  78. // onShareAppMessage() {
  79. // return {
  80. // title: '农工笔记',
  81. // path:'/pages/index/activity/activity'
  82. // }
  83. // },
  84. methods: {
  85. goComment(){
  86. this.addOrEditActiveComment();
  87. },
  88. closeShare(e){
  89. this.isShowShareModal = false;
  90. uni.showToast({
  91. title: "上传成功",
  92. icon: "none",
  93. duration: 2500,
  94. });
  95. setTimeout(()=>{uni.navigateBack({})},500)
  96. },
  97. getInfos(id){
  98. let md5Sign = md5(
  99. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  100. "&secret=" + getApp().globalData.secret
  101. );
  102. let url = getApp().globalData.shareUrl +"api/api.php" +"?method=activity&action=comment_info_by_id&timestamp=" +
  103. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  104. uni.request({
  105. url: url,
  106. method: "POST",
  107. header: {
  108. "content-type": "application/x-www-form-urlencoded",
  109. },
  110. data: {
  111. openid:getApp().globalData.open_id,
  112. id:id
  113. },
  114. success: (res) => {
  115. if (res.data.code === 200) {
  116. let obj = res.data.data;
  117. // this.recordId = obj.id;
  118. this.contentDesc = obj.content;
  119. // this.contentLink = obj.web_url;
  120. // this.uploadList = obj.pic_list.map((item)=>{return this.globalUrl + item.pic_url});
  121. // this.imgIdList = obj.pic_list.map((item)=>{return item.pic_id})
  122. }
  123. },
  124. fail: () => {
  125. console.log("连接失败");
  126. },
  127. });
  128. },
  129. addOrEditActiveComment(){
  130. let url,data;
  131. let md5Sign = md5(
  132. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  133. "&secret=" + getApp().globalData.secret
  134. );
  135. if(this.type === 'add'){
  136. url = getApp().globalData.shareUrl +"api/api.php" +"?method=activity&action=comment_add&timestamp=" +
  137. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  138. data = {
  139. openid:getApp().globalData.open_id,
  140. branch_id:this.branchId,
  141. activity_id:this.activeId,
  142. content:this.contentDesc,
  143. }
  144. }else {
  145. url = getApp().globalData.shareUrl +"api/api.php" +"?method=activity&action=comment_update&timestamp=" +
  146. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  147. data = {
  148. openid:getApp().globalData.open_id,
  149. id:this.recordId,
  150. branch_id:this.branchId,
  151. activity_id:this.activeId,
  152. content:this.contentDesc,
  153. }
  154. }
  155. uni.request({
  156. url: url,
  157. method: "POST",
  158. header: {
  159. "content-type": "application/x-www-form-urlencoded",
  160. },
  161. data:data,
  162. success: (res) => {
  163. if (res.data.code === 200) {
  164. if(this.type === 'edit'){
  165. uni.showToast({
  166. title: "修改成功",
  167. icon: "none",
  168. duration: 2500,
  169. });
  170. setTimeout(()=>{uni.navigateBack({})},500)
  171. }else {
  172. let types = 'add';
  173. let pages = getCurrentPages(); // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
  174. let nowPage = pages[pages.length - 1]; //当前页页面实例
  175. let prevPage = pages[pages.length - 2]; //上一页页面实例
  176. prevPage.$vm.pageShowShare(types,'comment')
  177. uni.showToast({
  178. title: "上传成功",
  179. icon: "none",
  180. duration: 2500,
  181. });
  182. setTimeout(()=>{uni.navigateBack({delta:1})},500)
  183. //this.isShowShareModal = true
  184. }
  185. }
  186. },
  187. fail: () => {
  188. console.log("连接失败");
  189. },
  190. });
  191. },
  192. }
  193. }
  194. </script>
  195. <style lang="scss" scoped>
  196. .content {
  197. &_list{
  198. display: flex;
  199. flex-direction: row;
  200. align-items: center;
  201. justify-content:space-around;
  202. &_lable{
  203. }
  204. &_content{
  205. flex: 1;
  206. width: auto;
  207. text-align: right;
  208. }
  209. }
  210. }
  211. .content-box {
  212. width: 100%;
  213. /* height: 100%; */
  214. display: flex;
  215. flex-direction: column;
  216. align-items: center;
  217. /* justify-content: center; */
  218. }
  219. .header-box {
  220. width: 85%;
  221. height:80rpx;
  222. border: .5px dotted #00A1B4;
  223. border-radius: 50rpx;
  224. display: flex;
  225. justify-content: center;
  226. align-items: center;
  227. font-size: 24rpx;
  228. color:#00A1B4 ;
  229. /* font-family: PingFangSC-Regular; */
  230. margin-top: 2%;
  231. }
  232. .header-box image {
  233. width: 36rpx;
  234. height: 36rpx;
  235. margin-right: 1%;
  236. }
  237. .self-title-box {
  238. width: 90%;
  239. display: flex;
  240. align-items: center;
  241. font-size: 32rpx;
  242. letter-spacing: 2rpx;
  243. color:#3C3C3C ;
  244. /* font-family: SimHei; */
  245. margin: 4% auto;
  246. font-weight: bold;
  247. height: 50rpx;
  248. line-height: 50rpx;
  249. }
  250. .self-title-box image {
  251. width: 6rpx;
  252. height: 32rpx;
  253. margin-right: 2%;
  254. }
  255. .info-box {
  256. width: 90%;
  257. margin: 3% auto;
  258. display: flex;
  259. flex-direction: column;
  260. // align-items: center;
  261. // height: 180rpx;
  262. }
  263. .info-title-box {
  264. display: flex;
  265. align-items: center;
  266. font-size: 28rpx;
  267. }
  268. .info-title-box image{
  269. width: 15rpx;
  270. height: 15rpx;
  271. margin-right: 2%;
  272. }
  273. .info-value-box {
  274. width: 100%;
  275. }
  276. .info-value-box input {
  277. height: 88rpx;
  278. background: #f7f7f7;
  279. font-size: 26rpx;
  280. padding-left: 4%;
  281. margin: 2% auto;
  282. }
  283. .info-value-box picker {
  284. position: relative;
  285. }
  286. .info-value-box picker image {
  287. position: absolute;
  288. width: 25rpx;
  289. height: 25rpx;
  290. right: 10px;
  291. top: 30rpx;
  292. }
  293. .select-box {
  294. height: 80rpx;
  295. background: #f7f7f7;
  296. font-size: 26rpx;
  297. padding-left: 4%;
  298. margin: 2% auto;
  299. color: #888;
  300. line-height: 88rpx;
  301. }
  302. .info-gender-box {
  303. width: 75%;
  304. font-size: 28rpx;
  305. }
  306. .form-radio {
  307. transform: scale(0.6);
  308. }
  309. .padding-left-2 {
  310. // padding-left: 2%;
  311. }
  312. .margin-right-10 {
  313. margin-right: 10%;
  314. }
  315. .border-line-box {
  316. width: 100%;
  317. height: 20rpx;
  318. background: #f7f7f7;
  319. }
  320. .picker-box{
  321. display: flex;
  322. align-items: center;
  323. justify-content: space-between;
  324. height: 60rpx;
  325. line-height: 60rpx;
  326. background: #f7f7f7;
  327. height: 88rpx;
  328. line-height: 88rpx;
  329. background: #f7f7f7;
  330. font-size: 28rpx;
  331. padding-left: 4%;
  332. }
  333. .uni-input image {
  334. width: 40rpx;
  335. height: 40rpx;
  336. margin-right: 2%;
  337. float: right;
  338. }
  339. .textarea-box {
  340. background: #f7f7f7;
  341. min-height: 120rpx;
  342. font-size: 28rpx;
  343. margin: 5% auto;
  344. padding: 4%;
  345. margin-bottom: 8%;
  346. }
  347. .upload-box {
  348. display: flex;
  349. flex-flow: column;
  350. width: 22%;
  351. height: 100rpx;
  352. border-radius: 10rpx;
  353. padding-top: 15rpx;
  354. }
  355. image {
  356. width: 100rpx;
  357. height:100rpx;
  358. }
  359. .upload-box-photo {
  360. width: 25%;
  361. height: 100rpx;
  362. border-radius: 10rpx;
  363. padding-top: 15rpx;
  364. position: relative;
  365. margin-left: 20rpx;
  366. margin-right: 20rpx;
  367. }
  368. .del-icon {
  369. position: absolute;
  370. right: -15rpx;
  371. width: 30rpx;
  372. height: 30rpx;
  373. }
  374. .update_button {
  375. text-align: center;
  376. display: flex;
  377. flex-wrap: wrap;
  378. }
  379. .picker-class {
  380. border-radius: 10rpx;
  381. padding: 10rpx;
  382. width: 73%;
  383. font-size: 28rpx;
  384. background: #f5f5f5;
  385. }
  386. .picker-class image {
  387. width: 26rpx;
  388. height: 26rpx;
  389. }
  390. .submit-bth {
  391. width: 25%;
  392. font-size: 26rpx;
  393. margin: 0 0 5% 0;
  394. color: #fff;
  395. }
  396. .select-member {
  397. input {
  398. margin: 2% 2% 2% 0;
  399. height: 80rpx;
  400. line-height: 80rpx;
  401. }
  402. button {
  403. background-color: #169bd5;
  404. margin: 0;
  405. height: 60rpx;
  406. line-height: 60rpx;
  407. width: 20%;
  408. }
  409. }
  410. .check-class {
  411. margin-right:10rpx;
  412. transform:scale(.8);
  413. width: 48%;
  414. margin-top: 2%;
  415. }
  416. .step-box {
  417. display: flex;
  418. justify-content: space-evenly;
  419. align-items: center;
  420. width: 90%;
  421. margin: 5% 0 5% 0;
  422. }
  423. .step-1 {
  424. width: 60rpx;
  425. height: 60rpx;
  426. border-radius: 50%;
  427. background-color:#aaaaaa;
  428. text-align: center;
  429. line-height: 60rpx;
  430. color: #fff;
  431. }
  432. .footer-box {
  433. margin-top: 5%;
  434. width: 90%;
  435. display: flex;
  436. justify-content: space-evenly;
  437. }
  438. .textarea-box {
  439. background: #f7f7f7;
  440. min-height: 120rpx;
  441. font-size: 28rpx;
  442. margin: 3% auto;
  443. padding: 4%;
  444. }
  445. .img-container{
  446. width: 90%;
  447. font-size: 26rpx;
  448. .note-image-box{
  449. margin-top: 5px;
  450. display: flex;
  451. flex-wrap: wrap;
  452. padding: 10px;
  453. .note-image-item{
  454. position: relative;
  455. //这两个百分比很关键
  456. width: 33.33%;
  457. height: 0;
  458. padding-top: 33.33%;
  459. box-sizing: border-box;
  460. .close-icon{
  461. display: flex;
  462. justify-content: center;
  463. align-items: center;
  464. position: absolute;
  465. right: 0;
  466. top: 0;
  467. width: 22px;
  468. height: 22px;
  469. border-radius: 50%;
  470. background-color: #d5d5d5;
  471. z-index: 2;
  472. }
  473. .image-box{
  474. display: flex;
  475. justify-content: center;
  476. align-items: center;
  477. position: absolute;
  478. top: 5px;
  479. right: 5px;
  480. bottom: 5px;
  481. left: 5px;
  482. border: 1px #eee solid;
  483. border-radius: 5px;
  484. overflow: hidden;
  485. image{
  486. width: 100%;
  487. height: 100%;
  488. }
  489. }
  490. }
  491. }
  492. }
  493. </style>