edit_page.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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="footer-box">
  77. <button type="primary" class="submit-bth" style="background-color: #169bd5;" @click="submitActive()">提交</button>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. import md5 from "@/common/md5.js";
  83. // import pickerAddress from '@/components/liudx-pickerAddress/index.vue'
  84. // var graceChecker = require("../../../common/graceChecker.js");
  85. export default {
  86. components: {
  87. },
  88. data() {
  89. return {
  90. isAuthPhone:getApp().globalData.user_phone,
  91. leaderAuth:'0',
  92. activeName:'',
  93. activeDate:'',
  94. activeValue:'请选择',
  95. activeType:['组织建设','参政议政','学习培训','社会活动'],
  96. rangeList:['全体成员可见','仅管理团队可见'],
  97. rangeValue:'全体成员可见',
  98. orgList:[],
  99. orgValue:'',
  100. orgId:'',
  101. orgRangeList:['全体成员可见','仅管理团队可见'],
  102. orgRangeValue:'全体成员可见',
  103. branchId:'',
  104. branchValue:'',
  105. lastPageLength:'',
  106. rangeId:'',
  107. orgId:'',
  108. orgRangeId:'',
  109. memberList: [],
  110. }
  111. },
  112. onLoad(option) {
  113. this.getInfoById(option.id)
  114. // let branchList = JSON.parse(option.list);
  115. // this.lastPageLength = option.length;
  116. // this.branchValue = branchList[0].name;
  117. // this.branchId = Number(branchList[0].id);
  118. // this.getPowerRequest(this.branchId);
  119. },
  120. onShow() {
  121. },
  122. // onShareAppMessage() {
  123. // return {
  124. // title: '分销小助手',
  125. // path:'/pages/index/index?scene=' + getApp().globalData.user_id
  126. // }
  127. // },
  128. methods: {
  129. bindDateChange(e){
  130. this.dateYear = e.target.value
  131. },
  132. bindDateMonthChange(e){
  133. this.dateMonth = this.arrayMonth[e.target.value]
  134. },
  135. change(e) {
  136. this.activeDate = e;
  137. console.log("-change事件:", e);
  138. },
  139. getInfoById(id){
  140. let md5Sign = md5(
  141. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  142. "&secret=" + getApp().globalData.secret
  143. );
  144. let url = getApp().globalData.shareUrl +"api/api.php" +"?method=activity&action=info_by_id&timestamp=" +
  145. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  146. uni.request({
  147. url: url,
  148. method: "POST",
  149. header: {
  150. "content-type": "application/x-www-form-urlencoded",
  151. },
  152. data: {
  153. openid:getApp().globalData.open_id,
  154. id:id
  155. },
  156. success: (res) => {
  157. if (res.data.code === 200) {
  158. let objInfo = res.data.data;
  159. this.branchId = objInfo.branch_id;
  160. this.activeId = objInfo.id;
  161. this.activeName = objInfo.name;
  162. this.activeDate = objInfo.start_time;
  163. this.activeValue = objInfo.type;
  164. this.rangeId = objInfo.post_leader_only;
  165. this.orgId = objInfo.leader_only;
  166. this.orgRangeId = objInfo.post_branch_level;
  167. this.getPowerRequest(this.branchId);
  168. }
  169. },
  170. fail: () => {
  171. console.log("连接失败");
  172. },
  173. });
  174. },
  175. goStepBack(){
  176. uni.navigateBack({
  177. })
  178. },
  179. bindPickerChange(e,type) {
  180. let that = this;
  181. switch (type){
  182. case 'activeType':
  183. that.activeValue = that.activeType[e.target.value]
  184. break;
  185. case 'range':
  186. that.rangeValue = that.rangeList[e.target.value]
  187. break;
  188. case 'org':
  189. that.orgValue = that.orgList[e.target.value].name;
  190. that.orgId = that.orgList[e.target.value].value;
  191. break;
  192. case 'orgRange':
  193. that.orgRangeValue = that.orgRangeList[e.target.value]
  194. break;
  195. }
  196. },
  197. getPowerRequest(bId){
  198. let rangeObj = {
  199. '0':'全体成员可见',
  200. '1':'仅管理团队可见',
  201. }
  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. this.leaderAuth = res.data.data.leader_auth;
  222. this.orgList = res.data.data.post_branch_level;
  223. this.rangeValue = rangeObj[this.rangeId];
  224. this.orgRangeValue = rangeObj[this.orgRangeId];
  225. if(this.orgList.length){
  226. this.orgValue = this.orgList.find((item)=>{return item.value == this.orgId}).name;
  227. }
  228. }
  229. },
  230. fail: () => {
  231. console.log("连接失败");
  232. },
  233. });
  234. },
  235. submitActive(){
  236. let typeObj = {
  237. '组织建设':'1',
  238. '参政议政':'2',
  239. '社会活动':'3',
  240. '学习培训':'4',
  241. }
  242. let rangeObj = {
  243. '全体成员可见':'0',
  244. '仅管理团队可见':'1',
  245. }
  246. let md5Sign = md5(
  247. "method=" +"activity" + "&timestamp=" + getApp().globalData.globalTimestamp +
  248. "&secret=" + getApp().globalData.secret
  249. );
  250. let url = getApp().globalData.shareUrl +"api/api.php" +
  251. "?method=activity&action=update&timestamp=" +
  252. getApp().globalData.globalTimestamp + "&sign=" + md5Sign;
  253. uni.request({
  254. url: url,
  255. method: "POST",
  256. header: {
  257. "content-type": "application/x-www-form-urlencoded",
  258. },
  259. data: {
  260. openid:getApp().globalData.open_id,
  261. id:this.activeId,
  262. name:this.activeName,
  263. type:typeObj[this.activeValue], //1.组织建设;2.参政议政;3.社会活动;4.学习培训;99.其他
  264. start_time:this.activeDate, //开始日期
  265. branch_id:this.branchId, //支部ID
  266. leader_only:rangeObj[this.rangeValue], //可见范围: 0,都可见;1, 仅管理层可见
  267. post_branch_level:this.orgId || '0', //下级支部可见层级
  268. post_leader_only:rangeObj[this.orgRangeValue], //下级支部可见范围: 0,都可见;1,仅管理层可见
  269. remark:'' //备注
  270. },
  271. success: (res) => {
  272. if (res.data.code === 200) {
  273. uni.showToast({
  274. title: "编辑成功",
  275. icon: "none",
  276. duration: 2500,
  277. });
  278. setTimeout(()=>{
  279. uni.navigateBack({})
  280. },800)
  281. }},
  282. fail: () => {
  283. console.log("连接失败");
  284. },
  285. });
  286. }
  287. }
  288. }
  289. </script>
  290. <style lang="scss" scoped>
  291. .content {
  292. &_list{
  293. display: flex;
  294. flex-direction: row;
  295. align-items: center;
  296. justify-content:space-around;
  297. &_lable{
  298. }
  299. &_content{
  300. flex: 1;
  301. width: auto;
  302. text-align: right;
  303. }
  304. }
  305. }
  306. .content-box {
  307. width: 100%;
  308. /* height: 100%; */
  309. display: flex;
  310. flex-direction: column;
  311. align-items: center;
  312. /* justify-content: center; */
  313. }
  314. .header-box {
  315. width: 85%;
  316. height:80rpx;
  317. border: .5px dotted #00A1B4;
  318. border-radius: 50rpx;
  319. display: flex;
  320. justify-content: center;
  321. align-items: center;
  322. font-size: 24rpx;
  323. color:#00A1B4 ;
  324. /* font-family: PingFangSC-Regular; */
  325. margin-top: 2%;
  326. }
  327. .header-box image {
  328. width: 36rpx;
  329. height: 36rpx;
  330. margin-right: 1%;
  331. }
  332. .self-title-box {
  333. width: 90%;
  334. display: flex;
  335. align-items: center;
  336. font-size: 32rpx;
  337. letter-spacing: 2rpx;
  338. color:#3C3C3C ;
  339. /* font-family: SimHei; */
  340. margin: 4% auto;
  341. font-weight: bold;
  342. height: 50rpx;
  343. line-height: 50rpx;
  344. }
  345. .self-title-box image {
  346. width: 6rpx;
  347. height: 32rpx;
  348. margin-right: 2%;
  349. }
  350. .info-box {
  351. width: 90%;
  352. margin: 2% auto;
  353. display: flex;
  354. flex-direction: column;
  355. // align-items: center;
  356. // height: 180rpx;
  357. }
  358. .info-title-box {
  359. display: flex;
  360. align-items: center;
  361. font-size: 28rpx;
  362. }
  363. .info-title-box image{
  364. width: 15rpx;
  365. height: 15rpx;
  366. margin-right: 2%;
  367. }
  368. .info-value-box {
  369. width: 100%;
  370. }
  371. .info-value-box input {
  372. height: 88rpx;
  373. background: #f7f7f7;
  374. font-size: 26rpx;
  375. padding-left: 4%;
  376. margin: 2% auto;
  377. }
  378. .info-value-box picker {
  379. position: relative;
  380. }
  381. .info-value-box picker image {
  382. position: absolute;
  383. width: 25rpx;
  384. height: 25rpx;
  385. right: 10px;
  386. top: 30rpx;
  387. }
  388. .select-box {
  389. height: 80rpx;
  390. background: #f7f7f7;
  391. font-size: 26rpx;
  392. padding-left: 4%;
  393. margin: 2% auto;
  394. color: #888;
  395. line-height: 88rpx;
  396. }
  397. .info-gender-box {
  398. width: 75%;
  399. font-size: 28rpx;
  400. }
  401. .form-radio {
  402. transform: scale(0.6);
  403. }
  404. .padding-left-2 {
  405. // padding-left: 2%;
  406. }
  407. .margin-right-10 {
  408. margin-right: 10%;
  409. }
  410. .border-line-box {
  411. width: 100%;
  412. height: 20rpx;
  413. background: #f7f7f7;
  414. }
  415. .picker-box{
  416. display: flex;
  417. align-items: center;
  418. justify-content: space-between;
  419. height: 60rpx;
  420. line-height: 60rpx;
  421. background: #f7f7f7;
  422. height: 88rpx;
  423. line-height: 88rpx;
  424. background: #f7f7f7;
  425. font-size: 28rpx;
  426. padding-left: 4%;
  427. }
  428. .uni-input image {
  429. width: 40rpx;
  430. height: 40rpx;
  431. margin-right: 2%;
  432. float: right;
  433. }
  434. .textarea-box {
  435. background: #f7f7f7;
  436. min-height: 120rpx;
  437. font-size: 28rpx;
  438. margin: 5% auto;
  439. padding: 4%;
  440. margin-bottom: 8%;
  441. }
  442. .upload-box {
  443. display: flex;
  444. flex-flow: column;
  445. width: 25%;
  446. height: 100rpx;
  447. border-radius: 10rpx;
  448. padding-top: 15rpx;
  449. image {
  450. width: 100rpx;
  451. height:100rpx;
  452. }
  453. }
  454. .upload-box-photo {
  455. width: 25%;
  456. height: 100rpx;
  457. border-radius: 10rpx;
  458. padding-top: 15rpx;
  459. position: relative;
  460. margin-left: 10rpx;
  461. }
  462. .del-icon {
  463. position: absolute;
  464. right: 0;
  465. width: 30rpx;
  466. height: 30rpx;
  467. }
  468. .update_button {
  469. text-align: center;
  470. display: flex;
  471. flex-wrap: wrap;
  472. }
  473. .picker-class {
  474. border-radius: 10rpx;
  475. padding: 10rpx;
  476. width: 73%;
  477. font-size: 28rpx;
  478. background: #f5f5f5;
  479. }
  480. .picker-class image {
  481. width: 26rpx;
  482. height: 26rpx;
  483. }
  484. .submit-bth {
  485. width: 25%;
  486. font-size: 26rpx;
  487. margin: 0 0 5% 0;
  488. color: #fff;
  489. }
  490. .select-member {
  491. input {
  492. margin: 2% 2% 2% 0;
  493. height: 80rpx;
  494. line-height: 80rpx;
  495. }
  496. button {
  497. background-color: #169bd5;
  498. margin: 0;
  499. height: 60rpx;
  500. line-height: 60rpx;
  501. width: 20%;
  502. }
  503. }
  504. .check-class {
  505. margin-right:10rpx;
  506. transform:scale(.8);
  507. width: 48%;
  508. margin-top: 2%;
  509. }
  510. .step-box {
  511. display: flex;
  512. justify-content: space-evenly;
  513. align-items: center;
  514. width: 90%;
  515. margin: 5% 0 5% 0;
  516. }
  517. .step-1 {
  518. width: 60rpx;
  519. height: 60rpx;
  520. border-radius: 50%;
  521. background-color:#aaaaaa;
  522. text-align: center;
  523. line-height: 60rpx;
  524. color: #fff;
  525. }
  526. .footer-box {
  527. margin-top: 15%;
  528. width: 90%;
  529. display: flex;
  530. justify-content: space-evenly;
  531. }
  532. </style>