issue.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <view>
  3. <u-navbar title="发布内容" back-icon-name="close" ref="refNavbar" >
  4. <view class="slot-wrap"
  5. :class="{
  6. 'slot-wrap-a':true,
  7. 'slot-wrap-b':subForm.synopsis
  8. }"
  9. @click="selectvideo()">
  10. 发布
  11. </view>
  12. </u-navbar>
  13. <textarea placeholder="记录点滴生活..."
  14. v-model="subForm.synopsis" maxlength="200"
  15. name="" id="" cols="30" rows="10"></textarea>
  16. <view style="float: right;">字数限制:{{subForm.synopsis?subForm.synopsis.length:0}}/200</view>
  17. <view class="upload">
  18. <u-upload-file ref="uUpload" :action="action"
  19. :max-size="50 * 1024 * 1024" :maxCount="9"
  20. :form-data="formData" :header="header"
  21. :file-list="fileList" ></u-upload-file>
  22. </view>
  23. <view class="select">
  24. <view class="join">
  25. <text class="sign">#</text>
  26. <text class="text">参与活动</text>
  27. </view>
  28. <view class="choose" @click="selectshare" >
  29. <text >{{itemshare.label?itemshare.label:'选择活动'}}</text>
  30. <u-icon name="arrow-right"></u-icon>
  31. </view>
  32. </view>
  33. <view style="padding: 10px;">每周只能发布一次 ,每周一重置次数</view>
  34. <view style="padding: 10px;">上传备注:<br/>1.最多上传9张(含图片\视频)
  35. <br/>2.单个文件大小限制为50M
  36. <br/> 3.图片一行显示3个,视频一行显示1个;
  37. <br/>4.发布后图片排列在视频前面,其余顺序按上传顺序排列</view>
  38. <view class="bottom" v-if="false" >
  39. <button>发布作品</button>
  40. </view>
  41. <u-select v-model="showshare" :default-value=[itemshare.index?itemshare.index:0] @confirm="confirmshare"
  42. value-name="index" label-name="title"
  43. :list="listshare"></u-select>
  44. </view>
  45. </template>
  46. <script>
  47. import * as API from '@/apis/pagejs/activity.js'
  48. import * as API_share from '@/apis/pagejs/share.js'
  49. export default {
  50. data() {
  51. return {
  52. listshare:[],
  53. itemshare:{},
  54. showshare:false,
  55. action:"",
  56. formData:{},
  57. fileList:[],
  58. header:{
  59. },
  60. nic:0,
  61. listForm:{
  62. pageIndex:1,
  63. pageSize:50,
  64. status:'7d69d622-3785-470e-b36c-d0f155b79dfa',
  65. },
  66. subForm:{
  67. },
  68. }
  69. },onLoad(op) {
  70. this.action=process.car.BASE_URL+"uploadPicture"
  71. this.formData.subFolder="mineissue"
  72. //接口应该免登陆
  73. var token=this.carhelp.getToken()
  74. this.header={
  75. 'Authorization':token
  76. }
  77. // //获取微信配置
  78. // WxJsApi.getWxConfig(['getLocation','addEventListener']).then((res)=>{
  79. // this.isReady=true;
  80. // //(res)
  81. // }).catch(error => {
  82. // //(res)
  83. // })
  84. if(op.id){
  85. this.itemshare.id=op.id;
  86. this.itemshare.index=-1;
  87. }
  88. if(op.nic){
  89. this.nic=op.nic;
  90. }
  91. this.getShareList()
  92. },
  93. methods:{
  94. confirmshare(es){
  95. var e=es[0]
  96. this.itemshare=e
  97. this.itemshare.index=e.value;
  98. },
  99. getShareList(){
  100. uni.showLoading({
  101. title: "加载中",
  102. mask: true,
  103. })
  104. API.pageList(this.listForm).then((res) => {
  105. uni.hideLoading();
  106. this.listshare = res.data.data;
  107. for(var i in this.listshare){
  108. var item=this.listshare[i]
  109. item.index=i;
  110. if(this.itemshare.index==-1){
  111. if(item.id==this.itemshare.id){
  112. this.confirmshare([{value:i,label:item.title}])
  113. }
  114. }
  115. }
  116. }).catch(error => {
  117. uni.showToast({
  118. title: error,
  119. icon: "none"
  120. })
  121. })
  122. },
  123. selectshare(){
  124. this.showshare=true;
  125. },
  126. selectvideo(){
  127. if(this.subForm.synopsis){
  128. }else{
  129. return
  130. }
  131. if(this.itemshare.label){
  132. this.subForm.activityId=this.listshare[this.itemshare.value].id;
  133. }
  134. var lists2 = this.$refs.uUpload.lists;
  135. var lists1 = [];
  136. var urls=[]
  137. var isPics=[]
  138. var bl=true;
  139. for(var i in lists2){
  140. //console.log(item.progress)
  141. //console.log(lists2[i])
  142. if(lists2[i].progress!=100){
  143. uni.showToast({
  144. title:"图片/视频上传中,请稍后"
  145. })
  146. bl=false
  147. break;
  148. }
  149. if(lists2[i].response){
  150. }else{
  151. continue;
  152. }
  153. var p =lists2[i].response.data;
  154. var fileName=p.fileName
  155. if(fileName.indexOf('.mp4')>=0){
  156. p.isPic=false
  157. }else{
  158. p.isPic=true
  159. }
  160. lists1.push(p);
  161. }
  162. if(!bl){
  163. return
  164. }
  165. uni.showLoading({
  166. title: "加载中",
  167. mask: true,
  168. })
  169. lists1=lists1.sort(function(item1,item2){
  170. if(!item1.isPic&&item2.isPic){
  171. return 1
  172. }
  173. if(item1.isPic&&!item2.isPic){
  174. return -1
  175. }
  176. if(item1.isPic&&item2.isPic){
  177. return 0
  178. }
  179. return 0
  180. })
  181. for(var i in lists1){
  182. var p =lists1[i];
  183. var fileName=p.fileName
  184. urls.push(p.fileUrl)
  185. isPics.push(p.isPic)
  186. }
  187. this.subForm.urls=urls.join()
  188. this.subForm.isPics=isPics.join()
  189. console.log(isPics.join())
  190. API_share.addShare(this.subForm).then((res) => {
  191. uni.hideLoading();
  192. this.carhelp.set("addShare",1);
  193. if(this.nic){
  194. uni.showModal({
  195. showCancel:false,
  196. title:"提示",
  197. content:"操作成功",
  198. cancelText:"确定",
  199. success: res1 => {
  200. this.$refs.refNavbar.goBack()
  201. }})
  202. }else{
  203. uni.showModal({
  204. title:"提示",
  205. content:"操作成功",
  206. confirmText:"前往分享空间",
  207. cancelText:"返回",
  208. success: res1 => {
  209. if (res1.confirm) {
  210. uni.redirectTo({
  211. url:"/pages/staffHome/filesonic"
  212. })
  213. }else{
  214. this.$refs.refNavbar.goBack()
  215. }
  216. }})
  217. }
  218. }).catch(error => {
  219. uni.showToast({
  220. title: error,
  221. icon: "none"
  222. })
  223. })
  224. }
  225. }
  226. }
  227. </script>
  228. <style scoped lang="scss">
  229. .bottom{
  230. padding: 16rpx 32rpx;
  231. background-color: #fff;
  232. position: fixed;
  233. bottom: 0;
  234. left: 0;
  235. right: 0;
  236. uni-button{
  237. border-radius: 8px;
  238. background-color: rgba(31, 74, 153, 1);
  239. color: rgba(255, 255, 255, 1);
  240. font-size: 16px;
  241. line-height: 40px;
  242. }
  243. }
  244. page{
  245. background-color: #fff;
  246. font-family: 'Regular';
  247. }
  248. /deep/.u-slot-content {
  249. display: block;
  250. text-align: right !important;
  251. margin-right: 16px;
  252. color: #333333;
  253. }
  254. /deep/.uicon-close{
  255. font-size: 32rpx !important;
  256. color: #101010 !important;
  257. }
  258. .slot-wrap-a{
  259. }
  260. .slot-wrap-b{
  261. background-color: #03a9f4 !important;
  262. }
  263. .slot-wrap{
  264. background-color: rgba(204, 204, 204, 1);
  265. width: 104rpx;
  266. height:56rpx;
  267. line-height:56rpx ;
  268. border-radius: 8px;
  269. color: #fff;
  270. text-align: center;
  271. position: absolute;
  272. top: 50%;
  273. right: 32rpx;
  274. transform: translateY(-50%);
  275. }
  276. uni-textarea{
  277. width: 100%;
  278. text-indent: 28rpx;
  279. padding-top:28rpx;
  280. font-family: Microsoft Yahei;
  281. }
  282. .upload{
  283. padding: 32rpx;
  284. /deep/.u-add-tips{
  285. // display: none;
  286. }
  287. }
  288. .select{
  289. display: flex;
  290. justify-content: space-between;
  291. padding: 0 32rpx;
  292. height: 56px;
  293. line-height: 56px;
  294. .join{
  295. color: rgba(16, 16, 16, 1);
  296. font-size: 16px;
  297. .sign{
  298. color: #1F4A99;
  299. margin-right: 8rpx;
  300. }
  301. }
  302. .choose{
  303. text{
  304. margin-right: 8rpx;
  305. }
  306. color: rgba(153, 153, 153, 1);
  307. }
  308. }
  309. </style>