create2.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. <template>
  2. <view class="content-box">
  3. <view class="step-box">
  4. <view class="step-1">1</view>
  5. <view style="color: #d7d7d7;font-size: 54rpx;">------</view>
  6. <view class="step-1" style="background-color:#02a7f0">2</view>
  7. </view>
  8. <view class="info-box">
  9. <view class="info-value-box">
  10. <input type="text" placeholder="请输入活动标题" v-model="activeName">
  11. </view>
  12. </view>
  13. <view class="info-box">
  14. <view class="info-title-box">
  15. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  16. <text>选择活动类型</text>
  17. </view>
  18. <view class="info-value-box">
  19. <picker @change="bindPickerChange($event,'activeType')" :range="activeType" class="select-box">
  20. <view class="uni-input">{{activeValue}}</view>
  21. <image src="/static/arrow_down.svg" mode="aspectFill"></image>
  22. </picker>
  23. </view>
  24. </view>
  25. <view class="info-box">
  26. <view class="info-title-box">
  27. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  28. <text>选择活动时间</text>
  29. </view>
  30. <view class="info-value-box" style=" width: 50%; margin-top: 2%;">
  31. <uni-datetime-picker
  32. class="time-select-box"
  33. type="date"
  34. :value="activeDate"
  35. @change="change"
  36. :clear-icon="false"
  37. />
  38. </view>
  39. </view>
  40. <view class="info-box" v-if="leaderAuth == '1'">
  41. <view class="info-title-box">
  42. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  43. <text>可见范围</text>
  44. </view>
  45. <view class="info-value-box">
  46. <picker @change="bindPickerChange($event,'range')" :range="rangeList" class="select-box">
  47. <view class="uni-input">{{rangeValue}}</view>
  48. <image src="/static/arrow_down.svg" mode="aspectFill"></image>
  49. </picker>
  50. </view>
  51. </view>
  52. <view class="info-box" v-if="orgList.length">
  53. <view class="info-title-box">
  54. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  55. <text>下级支部/组织可见</text>
  56. </view>
  57. <view class="info-value-box">
  58. <picker @change="bindPickerChange($event,'org')" :range="orgList" :range-key="'name'" class="select-box">
  59. <view class="uni-input">{{orgValue}}</view>
  60. <image src="/static/arrow_down.svg" mode="aspectFill"></image>
  61. </picker>
  62. </view>
  63. </view>
  64. <view class="info-box" v-if="orgList.length">
  65. <view class="info-title-box">
  66. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  67. <text>下级支部/组织可见范围</text>
  68. </view>
  69. <view class="info-value-box">
  70. <picker @change="bindPickerChange($event,'orgRange')" :range="orgRangeList" class="select-box">
  71. <view class="uni-input">{{orgRangeValue}}</view>
  72. <image src="/static/arrow_down.svg" mode="aspectFill"></image>
  73. </picker>
  74. </view>
  75. </view>
  76. <view class="info-box">
  77. <view class="info-title-box">
  78. <!-- <image src="/static/require-icon.png" mode="aspectFill"></image> -->
  79. <text>上传活动通知图片(非必填)</text>
  80. </view>
  81. <view class="info-value-box">
  82. <view class="update_button display-flex">
  83. <view class="upload-box" @click="getImage('album')">
  84. <view class="img" style="margin-top: 2%;">
  85. <image src="/static/upload-photo.png" class="photo"></image>
  86. </view>
  87. </view>
  88. <view
  89. class="display-flex upload-box-photo"
  90. v-for="(item, index) in uploadList"
  91. :key="index"
  92. >
  93. <image :src="item" mode="aspectFit" style="width: 100%; height: 100%" @click="showLarge(item)"/>
  94. <image src="/static/del.png" class="del-icon"mode="aspectFit"
  95. style="width: 30rpx; height: 30rpx" @click="delPhoto(index)"></image>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="footer-box">
  101. <button type="primary" class="submit-bth" style="background-color: #aaaaaa;" @click="goStepBack()">上一步</button>
  102. <button type="primary" class="submit-bth" style="background-color: #169bd5;" @click="submitActive()">提交</button>
  103. </view>
  104. </view>
  105. </template>
  106. <script>
  107. import md5 from "@/common/md5.js";
  108. // import pickerAddress from '@/components/liudx-pickerAddress/index.vue'
  109. // var graceChecker = require("../../../common/graceChecker.js");
  110. export default {
  111. components: {
  112. },
  113. data() {
  114. return {
  115. isAuthPhone:getApp().globalData.user_phone,
  116. leaderAuth:'0',
  117. activeName:'',
  118. activeDate:'',
  119. activeValue:'请选择',
  120. activeType:['组织建设','参政议政','学习培训','社会活动'],
  121. rangeList:['全体成员可见','仅管理团队可见'],
  122. rangeValue:'全体成员可见',
  123. orgList:[],
  124. orgValue:'',
  125. orgId:'',
  126. orgRangeList:['全体成员可见','仅管理团队可见'],
  127. orgRangeValue:'全体成员可见',
  128. branchId:'',
  129. branchValue:'',
  130. imgIdList: [],
  131. uploadList:[],
  132. lastPageLength:'',
  133. memberList: [
  134. {
  135. value: 'CHN',
  136. name: '全部人员'
  137. },
  138. {
  139. value: 'CHN',
  140. name: '管理团队',
  141. checked: 'true'
  142. },
  143. {
  144. value: 'CHN',
  145. name: '下级支部管理团队'
  146. },
  147. {
  148. value: 'CHN',
  149. name: '下级支部成员'
  150. },
  151. ],
  152. }
  153. },
  154. onLoad(option) {
  155. let branchList = JSON.parse(option.list);
  156. this.lastPageLength = option.length;
  157. this.branchValue = branchList[0].name;
  158. this.branchId = Number(branchList[0].id);
  159. this.getPowerRequest(this.branchId);
  160. },
  161. onShow() {
  162. },
  163. // onShareAppMessage() {
  164. // return {
  165. // title: '分销小助手',
  166. // path:'/pages/index/index?scene=' + getApp().globalData.user_id
  167. // }
  168. // },
  169. methods: {
  170. bindDateChange(e){
  171. this.dateYear = e.target.value
  172. },
  173. bindDateMonthChange(e){
  174. this.dateMonth = this.arrayMonth[e.target.value]
  175. },
  176. change(e) {
  177. this.activeDate = e;
  178. console.log("-change事件:", e);
  179. },
  180. goStepBack(){
  181. uni.navigateBack({
  182. })
  183. },
  184. bindPickerChange(e,type) {
  185. let that = this;
  186. switch (type){
  187. case 'activeType':
  188. that.activeValue = that.activeType[e.target.value]
  189. break;
  190. case 'range':
  191. that.rangeValue = that.rangeList[e.target.value]
  192. break;
  193. case 'org':
  194. that.orgValue = that.orgList[e.target.value].name;
  195. that.orgId = that.orgList[e.target.value].value;
  196. break;
  197. case 'orgRange':
  198. that.orgRangeValue = that.orgRangeList[e.target.value]
  199. break;
  200. }
  201. },
  202. getPowerRequest(bId){
  203. let md5Sign = md5(
  204. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  205. "&secret=" + getApp().globalData.secret
  206. );
  207. let url = getApp().globalData.shareUrl +"api/api.php" +
  208. "?method=activity&action=branch_auth&timestamp=" +
  209. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  210. uni.request({
  211. url: url,
  212. method: "POST",
  213. header: {
  214. "content-type": "application/x-www-form-urlencoded",
  215. },
  216. data: {
  217. openid:getApp().globalData.open_id,
  218. branch_id:bId
  219. },
  220. success: (res) => {
  221. if (res.data.code === 200) {
  222. console.log(res.data)
  223. this.leaderAuth = res.data.data.leader_auth;
  224. this.orgList = res.data.data.post_branch_level;
  225. console.log(this.orgList)
  226. if(this.orgList.length){
  227. this.orgValue = this.orgList[0].name;
  228. }
  229. }
  230. },
  231. fail: () => {
  232. console.log("连接失败");
  233. },
  234. });
  235. },
  236. getImage(type) {
  237. let that = this;
  238. if (that.uploadList.length >= 9) {
  239. uni.showToast({
  240. title: "最多上传9张图片",
  241. icon: "none",
  242. duration: 2500,
  243. });
  244. return;
  245. }
  246. uni.chooseImage({
  247. sourceType: [type],
  248. count: 9 - that.uploadList.length,
  249. sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
  250. success: (res) => {
  251. for (let i = 0; i < res.tempFilePaths.length; i++) {
  252. that.uploadList.push(res.tempFilePaths[i]);
  253. that.uploadFileRequest(res.tempFilePaths[i]);
  254. }
  255. },
  256. });
  257. },
  258. uploadFileRequest(fileVal) {
  259. uni.showLoading({
  260. title: "上传中",
  261. mask: true,
  262. });
  263. let that = this;
  264. let md5Sign = md5(
  265. "method="+"activity_upload" +"&timestamp=" + getApp().globalData.globalTimestamp + "&secret=" +getApp().globalData.secret
  266. );
  267. let url = getApp().globalData.shareUrl + "api/api.php" +"?method=activity_upload&timestamp=" +
  268. getApp().globalData.globalTimestamp +"&sign=" + md5Sign;
  269. uni.uploadFile({
  270. url: url, //需要设置为全局
  271. filePath: fileVal,
  272. name: "file",
  273. formData: {
  274. openid: getApp().globalData.open_id,
  275. file: fileVal,
  276. branch_id:this.branchId
  277. },
  278. success: (res) => {
  279. let tmpres = JSON.parse(res.data);
  280. console.log(tmpres)
  281. uni.hideLoading();
  282. that.imgIdList.push(tmpres.data.id);
  283. },
  284. fail: (res) => {
  285. console.log("上传请求失败");
  286. console.log(res);
  287. },
  288. });
  289. },
  290. delPhoto(idx) {
  291. this.uploadList.splice(idx, 1);
  292. this.imgIdList.splice(idx, 1);
  293. },
  294. showLarge(src) {
  295. uni.previewImage({
  296. urls: [src],
  297. longPressActions: {
  298. itemList: ["发送给朋友", "保存图片"],
  299. success: function (data) {},
  300. fail: function (err) {
  301. console.log(err.errMsg);
  302. },
  303. },
  304. });
  305. },
  306. submitActive(){
  307. let typeObj = {
  308. '组织建设':'1',
  309. '参政议政':'2',
  310. '社会活动':'3',
  311. '学习培训':'4',
  312. // '其他':'99',
  313. }
  314. let rangeObj = {
  315. '全体成员可见':'0',
  316. '仅管理团队可见':'1',
  317. }
  318. let md5Sign = md5(
  319. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  320. "&secret=" + getApp().globalData.secret
  321. );
  322. let url = getApp().globalData.shareUrl +"api/api.php" +
  323. "?method=activity&action=add&timestamp=" +
  324. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  325. uni.request({
  326. url: url,
  327. method: "POST",
  328. header: {
  329. "content-type": "application/x-www-form-urlencoded",
  330. },
  331. data: {
  332. openid:getApp().globalData.open_id,
  333. name:this.activeName,
  334. type:typeObj[this.activeValue], //1.组织建设;2.参政议政;3.社会活动;4.学习培训;99.其他
  335. start_time:this.activeDate, //开始日期
  336. branch_id:this.branchId, //支部ID
  337. leader_only:rangeObj[this.rangeValue], //可见范围: 0,都可见;1, 仅管理层可见
  338. post_branch_level:this.orgId || '0', //下级支部可见层级
  339. post_leader_only:rangeObj[this.orgRangeValue], //下级支部可见范围: 0,都可见;1,仅管理层可见
  340. attach_ids:this.imgIdList.join(), //活动通知附件ids,以逗号分隔 可没有
  341. remark:'' //备注
  342. },
  343. success: (res) => {
  344. if (res.data.code === 200) {
  345. uni.showToast({
  346. title: "添加成功",
  347. icon: "none",
  348. duration: 2500,
  349. });
  350. setTimeout(()=>{
  351. if(this.lastPageLength == 1){
  352. uni.navigateBack({delta:1})
  353. }else{
  354. uni.navigateBack({delta:2})
  355. }
  356. },800)
  357. }},
  358. fail: () => {
  359. console.log("连接失败");
  360. },
  361. });
  362. }
  363. }
  364. }
  365. </script>
  366. <style lang="scss" scoped>
  367. .content {
  368. &_list{
  369. display: flex;
  370. flex-direction: row;
  371. align-items: center;
  372. justify-content:space-around;
  373. &_lable{
  374. }
  375. &_content{
  376. flex: 1;
  377. width: auto;
  378. text-align: right;
  379. }
  380. }
  381. }
  382. .content-box {
  383. width: 100%;
  384. /* height: 100%; */
  385. display: flex;
  386. flex-direction: column;
  387. align-items: center;
  388. /* justify-content: center; */
  389. }
  390. .header-box {
  391. width: 85%;
  392. height:80rpx;
  393. border: .5px dotted #00A1B4;
  394. border-radius: 50rpx;
  395. display: flex;
  396. justify-content: center;
  397. align-items: center;
  398. font-size: 24rpx;
  399. color:#00A1B4 ;
  400. /* font-family: PingFangSC-Regular; */
  401. margin-top: 2%;
  402. }
  403. .header-box image {
  404. width: 36rpx;
  405. height: 36rpx;
  406. margin-right: 1%;
  407. }
  408. .self-title-box {
  409. width: 90%;
  410. display: flex;
  411. align-items: center;
  412. font-size: 32rpx;
  413. letter-spacing: 2rpx;
  414. color:#3C3C3C ;
  415. /* font-family: SimHei; */
  416. margin: 4% auto;
  417. font-weight: bold;
  418. height: 50rpx;
  419. line-height: 50rpx;
  420. }
  421. .self-title-box image {
  422. width: 6rpx;
  423. height: 32rpx;
  424. margin-right: 2%;
  425. }
  426. .info-box {
  427. width: 90%;
  428. margin: 2% auto;
  429. display: flex;
  430. flex-direction: column;
  431. // align-items: center;
  432. // height: 180rpx;
  433. }
  434. .info-title-box {
  435. display: flex;
  436. align-items: center;
  437. font-size: 28rpx;
  438. }
  439. .info-title-box image{
  440. width: 15rpx;
  441. height: 15rpx;
  442. margin-right: 2%;
  443. }
  444. .info-value-box {
  445. width: 100%;
  446. }
  447. .info-value-box input {
  448. height: 88rpx;
  449. background: #f7f7f7;
  450. font-size: 26rpx;
  451. padding-left: 4%;
  452. margin: 2% auto;
  453. }
  454. .info-value-box picker {
  455. position: relative;
  456. }
  457. .info-value-box picker image {
  458. position: absolute;
  459. width: 25rpx;
  460. height: 25rpx;
  461. right: 10px;
  462. top: 30rpx;
  463. }
  464. .select-box {
  465. height: 80rpx;
  466. background: #f7f7f7;
  467. font-size: 26rpx;
  468. padding-left: 4%;
  469. margin: 2% auto;
  470. color: #888;
  471. line-height: 88rpx;
  472. }
  473. .info-gender-box {
  474. width: 75%;
  475. font-size: 28rpx;
  476. }
  477. .form-radio {
  478. transform: scale(0.6);
  479. }
  480. .padding-left-2 {
  481. // padding-left: 2%;
  482. }
  483. .margin-right-10 {
  484. margin-right: 10%;
  485. }
  486. .border-line-box {
  487. width: 100%;
  488. height: 20rpx;
  489. background: #f7f7f7;
  490. }
  491. .picker-box{
  492. display: flex;
  493. align-items: center;
  494. justify-content: space-between;
  495. height: 60rpx;
  496. line-height: 60rpx;
  497. background: #f7f7f7;
  498. height: 88rpx;
  499. line-height: 88rpx;
  500. background: #f7f7f7;
  501. font-size: 28rpx;
  502. padding-left: 4%;
  503. }
  504. .uni-input image {
  505. width: 40rpx;
  506. height: 40rpx;
  507. margin-right: 2%;
  508. float: right;
  509. }
  510. .textarea-box {
  511. background: #f7f7f7;
  512. min-height: 120rpx;
  513. font-size: 28rpx;
  514. margin: 5% auto;
  515. padding: 4%;
  516. margin-bottom: 8%;
  517. }
  518. .upload-box {
  519. display: flex;
  520. flex-flow: column;
  521. width: 25%;
  522. height: 100rpx;
  523. border-radius: 10rpx;
  524. padding-top: 15rpx;
  525. image {
  526. width: 100rpx;
  527. height:100rpx;
  528. }
  529. }
  530. .upload-box-photo {
  531. width: 25%;
  532. height: 100rpx;
  533. border-radius: 10rpx;
  534. padding-top: 15rpx;
  535. position: relative;
  536. margin-left: 10rpx;
  537. }
  538. .del-icon {
  539. position: absolute;
  540. right: 0;
  541. width: 30rpx;
  542. height: 30rpx;
  543. }
  544. .update_button {
  545. text-align: center;
  546. display: flex;
  547. flex-wrap: wrap;
  548. }
  549. .picker-class {
  550. border-radius: 10rpx;
  551. padding: 10rpx;
  552. width: 73%;
  553. font-size: 28rpx;
  554. background: #f5f5f5;
  555. }
  556. .picker-class image {
  557. width: 26rpx;
  558. height: 26rpx;
  559. }
  560. .submit-bth {
  561. width: 25%;
  562. font-size: 26rpx;
  563. margin: 0 0 5% 0;
  564. color: #fff;
  565. }
  566. .select-member {
  567. input {
  568. margin: 2% 2% 2% 0;
  569. height: 80rpx;
  570. line-height: 80rpx;
  571. }
  572. button {
  573. background-color: #169bd5;
  574. margin: 0;
  575. height: 60rpx;
  576. line-height: 60rpx;
  577. width: 20%;
  578. }
  579. }
  580. .check-class {
  581. margin-right:10rpx;
  582. transform:scale(.8);
  583. width: 48%;
  584. margin-top: 2%;
  585. }
  586. .step-box {
  587. display: flex;
  588. justify-content: space-evenly;
  589. align-items: center;
  590. width: 90%;
  591. margin: 5% 0 5% 0;
  592. }
  593. .step-1 {
  594. width: 60rpx;
  595. height: 60rpx;
  596. border-radius: 50%;
  597. background-color:#aaaaaa;
  598. text-align: center;
  599. line-height: 60rpx;
  600. color: #fff;
  601. }
  602. .footer-box {
  603. margin-top: 15%;
  604. width: 90%;
  605. display: flex;
  606. justify-content: space-evenly;
  607. }
  608. </style>