create2.vue 17 KB

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