issue.vue 7.2 KB

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