create2.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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 || 1;
  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. if(!this.activeName){
  308. uni.showToast({
  309. title: "请填写活动标题",
  310. icon: "none",
  311. duration: 2500,
  312. });
  313. return
  314. }
  315. if(!this.activeDate){
  316. uni.showToast({
  317. title: "请选择活动时间",
  318. icon: "none",
  319. duration: 2500,
  320. });
  321. return
  322. }
  323. let typeObj = {
  324. '组织建设':'1',
  325. '参政议政':'2',
  326. '社会活动':'3',
  327. '学习培训':'4',
  328. // '其他':'99',
  329. }
  330. let rangeObj = {
  331. '全体成员可见':'0',
  332. '仅管理团队可见':'1',
  333. }
  334. let md5Sign = md5(
  335. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  336. "&secret=" + getApp().globalData.secret
  337. );
  338. let url = getApp().globalData.shareUrl +"api/api.php" +
  339. "?method=activity&action=add&timestamp=" +
  340. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  341. uni.request({
  342. url: url,
  343. method: "POST",
  344. header: {
  345. "content-type": "application/x-www-form-urlencoded",
  346. },
  347. data: {
  348. openid:getApp().globalData.open_id,
  349. name:this.activeName,
  350. type:typeObj[this.activeValue], //1.组织建设;2.参政议政;3.社会活动;4.学习培训;99.其他
  351. start_time:this.activeDate, //开始日期
  352. branch_id:this.branchId, //支部ID
  353. leader_only:rangeObj[this.rangeValue], //可见范围: 0,都可见;1, 仅管理层可见
  354. post_branch_level:this.orgId || '0', //下级支部可见层级
  355. post_leader_only:rangeObj[this.orgRangeValue], //下级支部可见范围: 0,都可见;1,仅管理层可见
  356. attach_ids:this.imgIdList.join(), //活动通知附件ids,以逗号分隔 可没有
  357. remark:'' //备注
  358. },
  359. success: (res) => {
  360. if (res.data.code === 200) {
  361. uni.showToast({
  362. title: "添加成功",
  363. icon: "none",
  364. duration: 2500,
  365. });
  366. let types = 'add';
  367. let pages = getCurrentPages(); // 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
  368. setTimeout(()=>{
  369. if(this.lastPageLength == 1){
  370. let nowPage = pages[pages.length - 1]; //当前页页面实例
  371. let prevPage = pages[pages.length - 2]; //上一页页面实例
  372. prevPage.$vm.pageRefresh(types)
  373. uni.navigateBack({delta:1})
  374. }else{
  375. let nowPage = pages[pages.length - 1]; //当前页页面实例
  376. let prevPage = pages[pages.length - 3]; //上一页页面实例
  377. prevPage.$vm.pageRefresh(types)
  378. uni.navigateBack({delta:2})
  379. }
  380. },800)
  381. }},
  382. fail: () => {
  383. console.log("连接失败");
  384. },
  385. });
  386. }
  387. }
  388. }
  389. </script>
  390. <style lang="scss" scoped>
  391. .content {
  392. &_list{
  393. display: flex;
  394. flex-direction: row;
  395. align-items: center;
  396. justify-content:space-around;
  397. &_lable{
  398. }
  399. &_content{
  400. flex: 1;
  401. width: auto;
  402. text-align: right;
  403. }
  404. }
  405. }
  406. .content-box {
  407. width: 100%;
  408. /* height: 100%; */
  409. display: flex;
  410. flex-direction: column;
  411. align-items: center;
  412. /* justify-content: center; */
  413. }
  414. .header-box {
  415. width: 85%;
  416. height:80rpx;
  417. border: .5px dotted #00A1B4;
  418. border-radius: 50rpx;
  419. display: flex;
  420. justify-content: center;
  421. align-items: center;
  422. font-size: 24rpx;
  423. color:#00A1B4 ;
  424. /* font-family: PingFangSC-Regular; */
  425. margin-top: 2%;
  426. }
  427. .header-box image {
  428. width: 36rpx;
  429. height: 36rpx;
  430. margin-right: 1%;
  431. }
  432. .self-title-box {
  433. width: 90%;
  434. display: flex;
  435. align-items: center;
  436. font-size: 32rpx;
  437. letter-spacing: 2rpx;
  438. color:#3C3C3C ;
  439. /* font-family: SimHei; */
  440. margin: 4% auto;
  441. font-weight: bold;
  442. height: 50rpx;
  443. line-height: 50rpx;
  444. }
  445. .self-title-box image {
  446. width: 6rpx;
  447. height: 32rpx;
  448. margin-right: 2%;
  449. }
  450. .info-box {
  451. width: 90%;
  452. margin: 2% auto;
  453. display: flex;
  454. flex-direction: column;
  455. // align-items: center;
  456. // height: 180rpx;
  457. }
  458. .info-title-box {
  459. display: flex;
  460. align-items: center;
  461. font-size: 28rpx;
  462. }
  463. .info-title-box image{
  464. width: 15rpx;
  465. height: 15rpx;
  466. margin-right: 2%;
  467. }
  468. .info-value-box {
  469. width: 100%;
  470. }
  471. .info-value-box input {
  472. height: 88rpx;
  473. background: #f7f7f7;
  474. font-size: 26rpx;
  475. padding-left: 4%;
  476. margin: 2% auto;
  477. }
  478. .info-value-box picker {
  479. position: relative;
  480. }
  481. .info-value-box picker image {
  482. position: absolute;
  483. width: 25rpx;
  484. height: 25rpx;
  485. right: 10px;
  486. top: 30rpx;
  487. }
  488. .select-box {
  489. height: 80rpx;
  490. background: #f7f7f7;
  491. font-size: 26rpx;
  492. padding-left: 4%;
  493. margin: 2% auto;
  494. color: #888;
  495. line-height: 88rpx;
  496. }
  497. .info-gender-box {
  498. width: 75%;
  499. font-size: 28rpx;
  500. }
  501. .form-radio {
  502. transform: scale(0.6);
  503. }
  504. .padding-left-2 {
  505. // padding-left: 2%;
  506. }
  507. .margin-right-10 {
  508. margin-right: 10%;
  509. }
  510. .border-line-box {
  511. width: 100%;
  512. height: 20rpx;
  513. background: #f7f7f7;
  514. }
  515. .picker-box{
  516. display: flex;
  517. align-items: center;
  518. justify-content: space-between;
  519. height: 60rpx;
  520. line-height: 60rpx;
  521. background: #f7f7f7;
  522. height: 88rpx;
  523. line-height: 88rpx;
  524. background: #f7f7f7;
  525. font-size: 28rpx;
  526. padding-left: 4%;
  527. }
  528. .uni-input image {
  529. width: 40rpx;
  530. height: 40rpx;
  531. margin-right: 2%;
  532. float: right;
  533. }
  534. .textarea-box {
  535. background: #f7f7f7;
  536. min-height: 120rpx;
  537. font-size: 28rpx;
  538. margin: 5% auto;
  539. padding: 4%;
  540. margin-bottom: 8%;
  541. }
  542. .upload-box {
  543. display: flex;
  544. flex-flow: column;
  545. width: 25%;
  546. height: 100rpx;
  547. border-radius: 10rpx;
  548. padding-top: 15rpx;
  549. image {
  550. width: 100rpx;
  551. height:100rpx;
  552. }
  553. }
  554. .upload-box-photo {
  555. width: 25%;
  556. height: 100rpx;
  557. border-radius: 10rpx;
  558. padding-top: 15rpx;
  559. position: relative;
  560. margin-left: 10rpx;
  561. }
  562. .del-icon {
  563. position: absolute;
  564. right: 0;
  565. width: 30rpx;
  566. height: 30rpx;
  567. }
  568. .update_button {
  569. text-align: center;
  570. display: flex;
  571. flex-wrap: wrap;
  572. }
  573. .picker-class {
  574. border-radius: 10rpx;
  575. padding: 10rpx;
  576. width: 73%;
  577. font-size: 28rpx;
  578. background: #f5f5f5;
  579. }
  580. .picker-class image {
  581. width: 26rpx;
  582. height: 26rpx;
  583. }
  584. .submit-bth {
  585. width: 25%;
  586. font-size: 26rpx;
  587. margin: 0 0 5% 0;
  588. color: #fff;
  589. }
  590. .select-member {
  591. input {
  592. margin: 2% 2% 2% 0;
  593. height: 80rpx;
  594. line-height: 80rpx;
  595. }
  596. button {
  597. background-color: #169bd5;
  598. margin: 0;
  599. height: 60rpx;
  600. line-height: 60rpx;
  601. width: 20%;
  602. }
  603. }
  604. .check-class {
  605. margin-right:10rpx;
  606. transform:scale(.8);
  607. width: 48%;
  608. margin-top: 2%;
  609. }
  610. .step-box {
  611. display: flex;
  612. justify-content: space-evenly;
  613. align-items: center;
  614. width: 90%;
  615. margin: 5% 0 5% 0;
  616. }
  617. .step-1 {
  618. width: 60rpx;
  619. height: 60rpx;
  620. border-radius: 50%;
  621. background-color:#aaaaaa;
  622. text-align: center;
  623. line-height: 60rpx;
  624. color: #fff;
  625. }
  626. .footer-box {
  627. margin-top: 15%;
  628. width: 90%;
  629. display: flex;
  630. justify-content: space-evenly;
  631. }
  632. </style>