enable.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. <template>
  2. <view class="content">
  3. <header-title :title="'收款码'+$test.$test"></header-title>
  4. <view class="main">
  5. <view class="box-pack-between ft32 item flex-y-center">
  6. <text>收款码 <text style="color:red">*</text> <text class="tips">(扫码/相册选取)</text></text>
  7. <image @click="qrcode" class="qrupimg" data-type="1" src="../../static/images/saoma.png" mode=""></image>
  8. </view>
  9. <view class="qr_content box-pack-between">
  10. <view></view>
  11. <view>
  12. <view class="qr_content_img" v-for="(item,index) of qr_arr" :key="index">
  13. <image class="qr_content_img_li" :src="item.img" mode=""></image>
  14. <image @click="qr_del" :data-index="index" class="qr_content_img_del" src="../../static/images/shanchu.png" mode=""></image>
  15. </view>
  16. </view>
  17. </view>
  18. <!-- <block v-if="moshi==2"> -->
  19. <FlowPool :thismoshi="moshi" :rule_arr_val="ruleArr" :this_moshi_type="moshi_type" :list_way="list_way" @ondel="binddel"
  20. @oncheck="bindcheck" @onTime='bindtime' @confirm="bindConfirm" @bindlevel="bindlevel"></FlowPool>
  21. <!-- </block> -->
  22. <view v-if="moshi==1">
  23. <view class="box-pack-between ft32 item">
  24. <text>{{$test.$test}}场景 </text>
  25. <view class="add-home flex-center ft24">
  26. <picker @change="bindPickerChange" :range-key="'name'" :range="allwayList">
  27. 添加
  28. </picker>
  29. </view>
  30. </view>
  31. <view class="item-bg" v-if="arr.length>0">
  32. <view class="box-pack-between mar64 flex-y-center" v-for="(item,index) of arr" :key='item.id'>
  33. <view class="flex-y-center flex-grow-1 pdr-20">
  34. <text style="margin-right: 10rpx;">{{item.name}}</text>
  35. <input class="flex-grow-1" type="text" @input="getScene" :data-index="index" placeholder="请填写链接或内容"
  36. :value="item.way_power" maxlength="5000" />
  37. </view>
  38. <image class="item-del" @click="delScene" :data-index='index' src="../../static/images/del.png" mode=""></image>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="">
  43. <view class="box-pack-between ft32 item">
  44. <text>配置中转页</text>
  45. <view class="flex-center ft24">
  46. <switch @change="bindMidState" :checked="mid_state==1?true:false" style="transform:scale(0.7)" />
  47. </view>
  48. </view>
  49. <!-- is_mid -->
  50. <view class="item-bg" v-if="mid_state==1?true:false">
  51. <view class="box-pack-between mgr57">
  52. <view class="flex-row">
  53. <text class="item-bg-32">中转页标题</text>
  54. <input type="text" @input="bindMidTitle" :value="mid_title" placeholder="请填写中转页标题" />
  55. </view>
  56. </view>
  57. <block v-if="Advertising.length>0">
  58. <view class="box-pack-between mgr57">
  59. <text class="item-bg-32" :data-index="Advertising[Adver_index].id">广告方式</text>
  60. <!-- <input style="display: none;" name="id" :value="Advertising[Adver_index].id" /> -->
  61. <picker @change="bindPickerAdvertising" :range-key="'name'" :range="Advertising">
  62. <text>{{Advertising[Adver_index].name}} <text class="iconfont icon-prev"></text></text>
  63. </picker>
  64. </view>
  65. <view class="box-pack-between flex-y-center" v-if="Advertising[Adver_index].name=='自定义引导页'">
  66. <text class="item-bg-32">广告引导页</text>
  67. <image @click="ChooseImage" data-type="2" v-if="mid_img" class="upimg" :data-url="Advertising[Adver_index].url"
  68. :src="URL+mid_img"></image>
  69. <image @click="ChooseImage" data-type="2" v-else class="upimg" src="../../static/images/upimg.png" mode=""></image>
  70. </view>
  71. <view class="box-pack-between flex-y-center" v-else-if="Advertising[Adver_index].name=='安全认证'">
  72. <text class="item-bg-32">广告引导页</text>
  73. <image mode="aspectFill" data-url="../../merchant/static/images/ali_ua.png" class="upimg" src="../../merchant/static/images/ali_ua.png"></image>
  74. <image mode="aspectFill" data-url="../../merchant/static/images/wx_ua.png" class="upimg" src="../../merchant/static/images/wx_ua.png"></image>
  75. <image mode="aspectFill" data-url="../../merchant/static/images/web_ua.png" class="upimg" src="../../merchant/static/images/web_ua.png"></image>
  76. </view>
  77. <view class="box-pack-between flex-y-center" v-else>
  78. <text class="item-bg-32">广告引导页</text>
  79. <image @click="Choose_img" mode="aspectFill" :data-url="URL+Advertising[Adver_index].url" class="upimg" :src="URL+Advertising[Adver_index].url"></image>
  80. </view>
  81. </block>
  82. </view>
  83. <text style="padding:0 40rpx;font-size: 12px;color: #999;">ps:{{$test.$test}}微信/支付宝钱包收款码,请勿关闭中转页</text>
  84. </view>
  85. <view class="box-pack-between ft32 item" v-if="mid_state==1?false:true">
  86. <text>开启遮盖指引</text>
  87. <view class="flex-center ft24">
  88. <switch :checked="hj_state==1?true:false" @change="bindHj" style="transform:scale(0.7)" />
  89. </view>
  90. </view>
  91. <view class="box-pack-between ft32 descp ">
  92. <textarea :value="description" @input="binddesc" maxlength="200" placeholder-class="desc-placeholder" :placeholder="$test.$test+'备注'"
  93. name='description' />
  94. </view>
  95. <view class="box-pack-between ft32 item">
  96. <view class="flex-center">
  97. <text>加入换量记录池</text>
  98. </view>
  99. <view class=" flex-center ft24">
  100. <switch name="is_exchange" @change="bindHl" :checked="is_exchange=='Y'?true:false" style="transform:scale(0.7)" />
  101. </view>
  102. </view>
  103. <view class="hg200rpx">
  104. </view>
  105. <view class="bottom-bar">
  106. <block v-if="card_num">
  107. <button @click="ScCode" type="2" class="btn2 flex-center">
  108. 确定修改
  109. </button>
  110. </block>
  111. <block v-else>
  112. <button @click="bangCode" type="1" class="btn1 flex-center">
  113. 绑定二维码
  114. </button>
  115. <button @click="ScCode" type="2" class="btn2 flex-center">
  116. 生成二维码
  117. </button>
  118. </block>
  119. </view>
  120. </view>
  121. </view>
  122. </template>
  123. <script>
  124. import HeaderTitle from '@/components/header/header-title.vue';
  125. import FlowPool from '@/components/flow-pool/flow-pool.vue';
  126. // #ifdef H5
  127. import getWXSign from "@/static/js/config.js";
  128. // #endif
  129. export default {
  130. components: {
  131. HeaderTitle,
  132. FlowPool,
  133. },
  134. data() {
  135. /*
  136. @param allwayList=[] 赋能平台
  137. @param arr 赋能内容
  138. @param result 绑定二维码链接
  139. @param url 二维码跳转链接
  140. @param URL 前缀链接
  141. @param card_num 卡号
  142. @param Advertising=[] 引导页数组
  143. @param Adver_index 引导页数组下标
  144. @param mid_type 判断引导页 中转类型
  145. @param mid_img 引导页自定义图片
  146. @param mid_state 引导页开启1 关闭2
  147. @param mid_title 引导页标题
  148. @param info 编辑返回数据
  149. @param qr_arr=[] 二维码内容
  150. */
  151. return {
  152. $test:this.$test.$test,
  153. act_index_time: 0,
  154. allwayList: [],
  155. arr: [],
  156. result: "",
  157. img_file: "",
  158. url: "",
  159. URL: getApp().globalData.URL,
  160. card_num: "",
  161. Advertising: [],
  162. Adver_index: 0,
  163. mid_type: "",
  164. mid_img: "",
  165. mid_state: 1,
  166. mid_title:"",
  167. hj_state:2,
  168. info: {},
  169. qr_arr: [],
  170. description:"",
  171. is_exchange:'N',
  172. moshi:1,
  173. moshi_type:2,
  174. list_way:[],
  175. ruleArr:[],
  176. powerpool_id:"",
  177. level_arr:[1,2,3],
  178. level:"",
  179. rule:"",
  180. }
  181. },
  182. onLoad(e) {
  183. uni.removeStorageSync("list_way");
  184. this.card_num = e.card_num;
  185. uni.setNavigationBarTitle({
  186. title:`收款码${this.$test.$test}`
  187. })
  188. if (!this.card_num) {
  189. this.allmuban();
  190. }
  191. this.allways();
  192. this.level=this.level_arr.join(",");
  193. },
  194. onShow() {
  195. // var aaa="https://payapp.weixin.qq.com"
  196. // console.log(aaa.length,"aaa")
  197. if(uni.getStorageSync("list_way")){
  198. this.list_way=uni.getStorageSync("list_way");
  199. if(this.way_index==3){
  200. for(let i of this.list_way){
  201. if(i.checked){
  202. this.powerpool_id=i.id
  203. }
  204. }
  205. }
  206. }
  207. },
  208. onHide(e) {
  209. },
  210. methods: {
  211. /*
  212. * @param bindMidState 中转页开关
  213. * @param Choose_img 预览图片
  214. * @param allmuban 中转页设置方式
  215. * @param getScene 赋能场景输入监听
  216. * @param delScene 赋能场景删除
  217. * @param bindPickerAdvertising 中转页选择确认
  218. * @param bindPickerChange 赋能场景确认
  219. * @param allways 赋能场景数据加载
  220. * @param qr_del 删除收款码
  221. * @param qrcode 扫码收款码
  222. * @param edit_detail 编辑内容
  223. * @param ScCode 生成二维码/修改二维码
  224. * @param Submit 保存/编辑
  225. * @param ChooseImage 上传图片
  226. * @param https 保存的公共方法
  227. * @param bangCode 绑定二维码
  228. * @param
  229. */
  230. // 流量池
  231. bindcheck(index) {
  232. uni.removeStorageSync("list_way");
  233. this.moshi = index;
  234. },
  235. binddel(index){
  236. this.list_way.splice(index, 1);
  237. },
  238. bindtime(index) {
  239. console.log("000",index)
  240. this.list_way=[];
  241. uni.removeStorageSync("list_way");
  242. this.moshi_type=index==1?1:2;
  243. this.way_index=index;
  244. if(index==1){
  245. uni.navigateTo({
  246. url: "../public/index"
  247. })
  248. }
  249. // 默认流量池
  250. if(index==3){
  251. uni.navigateTo({
  252. url: "../public/index?type=2"
  253. })
  254. }
  255. },
  256. // 获取时间
  257. bindConfirm(rule){
  258. console.log(rule,"aff")
  259. this.rule=rule;
  260. },
  261. bindlevel(e){
  262. console.log(e,"bindlevel")
  263. var level=[];
  264. for(var i of e){
  265. level.push(i.level)
  266. }
  267. this.level=level.join(",");
  268. },
  269. // 流量池end
  270. bindMidTitle(e){
  271. this.mid_title= e.detail.value;
  272. },
  273. bindMidState(e) {
  274. this.mid_state = e.target.value?1:2;
  275. },
  276. bindHj(e){
  277. this.hj_state = e.target.value?1:2;
  278. },
  279. bindHl(e){
  280. console.log( e.target.value)
  281. this.is_exchange = e.target.value?"Y":"N";
  282. },
  283. Choose_img(e) {
  284. var url = e.currentTarget.dataset.url
  285. uni.previewImage({
  286. urls: [url],
  287. })
  288. },
  289. binddesc(e){
  290. this.description = e.detail.value
  291. },
  292. allmuban() {
  293. this.request({
  294. url: "funeng/allmuban",
  295. }).then(res => {
  296. console.log(res, "res")
  297. if (res.code === '200') {
  298. res.data.push({
  299. name: "自定义引导页",
  300. id: "0",
  301. });
  302. if (this.card_num) {
  303. for (let i in res.data) {
  304. if (res.data[i].id == this.mid_type) {
  305. this.Adver_index = i;
  306. }
  307. }
  308. }
  309. this.Advertising = res.data;
  310. }
  311. }).catch((res) => {});
  312. },
  313. getScene(e) {
  314. var index = e.currentTarget.dataset.index;
  315. this.arr[index].way_power = e.detail.value;
  316. },
  317. delScene(e) {
  318. var index = Number(e.currentTarget.dataset.index);
  319. this.arr.splice(index,1);
  320. },
  321. bindPickerAdvertising(e) {
  322. this.Adver_index = e.detail.value;
  323. this.mid_img = "";
  324. },
  325. bindPickerChange: function(e) {
  326. console.log(e,this.allwayList, "bindPickerChange",)
  327. if (this.arr.length > 0) {
  328. for (let i of this.arr) {
  329. if (i.id == this.allwayList[e.target.value].id) {
  330. uni.showToast({
  331. title: "场景重复",
  332. icon: 'none'
  333. })
  334. return
  335. }
  336. }
  337. }
  338. this.arr.push({
  339. id:this.allwayList[e.target.value].id,
  340. name:this.allwayList[e.target.value].name,
  341. super_id:this.allwayList[e.target.value].super_id,
  342. });
  343. },
  344. allways() {
  345. this.request({
  346. url: "funeng/allways",
  347. data: {},
  348. }).then(res => {
  349. console.log(res, "res")
  350. if (res.code === '200') {
  351. this.allwayList=res.data;
  352. this.arr.push({
  353. id: res.data[0].id,
  354. name:res.data[0].name,
  355. super_id:res.data[0].super_id,
  356. });
  357. if (this.card_num) {
  358. this.edit_detail();
  359. }
  360. }
  361. }).catch((res) => {});
  362. },
  363. qr_del(e) {
  364. var index = e.currentTarget.dataset.index;
  365. this.qr_arr.splice(index, 1)
  366. },
  367. qrcode(e) {
  368. // #ifdef MP-WEIXIN
  369. uni.scanCode({
  370. scanType:['barCode', 'qrCode','datamatrix','pdf41'],
  371. success: (res) => {
  372. console.log('条码内容:',res,res.result);
  373. var result = res.result,
  374. qr_arr = this.qr_arr;
  375. console.log('内容:',result.substr(0, 28));
  376. if (result.substr(0, 3) == "wxp" || result.substr(0, 28) =="https://payapp.weixin.qq.com" ) {
  377. uni.showModal({
  378. title: '提示',
  379. content: '因接口调整,暂不支持微信收款码',
  380. showCancel: false,
  381. cancelText: '取消',
  382. confirmText: '确定',
  383. success: res => {},
  384. fail: () => {},
  385. complete: () => {}
  386. });
  387. return
  388. qr_arr.push({
  389. url: result,
  390. img: "../../static/images/pay_wx.png",
  391. type: 1
  392. })
  393. } else if (result.substr(0, 17) == "HTTPS://QR.ALIPAY" || result.substr(0, 17) == "https://qr.alipay") {
  394. qr_arr.push({
  395. url: result,
  396. img: "../../static/images/pay_ali.png",
  397. type: 2
  398. })
  399. } else if(result.substr(0, 17) =="https://i.qianbao")
  400. {
  401. qr_arr.push({
  402. url: result,
  403. img: "../../static/images/qq.com",
  404. type: 5
  405. })
  406. }
  407. else {
  408. qr_arr.push({
  409. url: result,
  410. img: "../../static/images/pay_jh.png",
  411. type: 3
  412. })
  413. }
  414. this.qr_arr = uniqeByKeys(qr_arr, ['type']);
  415. console.log(this.qr_arr, "qr_arr")
  416. //将对象元素转换成字符串以作比较
  417. function obj2key(obj, keys) {
  418. var n = keys.length,
  419. key = [];
  420. while (n--) {
  421. key.push(obj[keys[n]]);
  422. }
  423. return key.join('|');
  424. }
  425. //去重操作
  426. function uniqeByKeys(array, keys) {
  427. var arr = [];
  428. var hash = {};
  429. for (var i = 0, j = array.length; i < j; i++) {
  430. var k = obj2key(array[i], keys);
  431. if (!(k in hash)) {
  432. hash[k] = true;
  433. arr.push(array[i]);
  434. }
  435. }
  436. return arr;
  437. }
  438. },
  439. })
  440. // #endif
  441. // #ifdef H5
  442. getWXSign().then(res => {
  443. console.log('wx_getLocation');
  444. this.$wx.scanQRCode({
  445. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  446. scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  447. success: (res) => {
  448. console.log(res, "qrCode")
  449. var result = res.resultStr,
  450. qr_arr = this.qr_arr;
  451. if (result.substr(0, 3) == "wxp") {
  452. qr_arr.push({
  453. url: result,
  454. img: "../../static/images/pay_wx.png",
  455. type: 1
  456. })
  457. } else if (result.substr(0, 17) == "HTTPS://QR.ALIPAY" || result.substr(0, 10) == "https://qr.alipay") {
  458. qr_arr.push({
  459. url: result,
  460. img: "../../static/images/pay_ali.png",
  461. type: 2
  462. })
  463. }
  464. else if(result.substr(0, 17) =="https://i.qianbao"){
  465. qr_arr.push({
  466. url: result,
  467. img: "../../static/images/qq.com",
  468. type: 5
  469. })
  470. }else {
  471. qr_arr.push({
  472. url: result,
  473. img: "../../static/images/pay_jh.png",
  474. type: 3
  475. })
  476. }
  477. this.qr_arr = uniqeByKeys(qr_arr, ['type']);
  478. console.log(this.qr_arr, "qr_arr")
  479. //将对象元素转换成字符串以作比较
  480. function obj2key(obj, keys) {
  481. var n = keys.length,
  482. key = [];
  483. while (n--) {
  484. key.push(obj[keys[n]]);
  485. }
  486. return key.join('|');
  487. }
  488. //去重操作
  489. function uniqeByKeys(array, keys) {
  490. var arr = [];
  491. var hash = {};
  492. for (var i = 0, j = array.length; i < j; i++) {
  493. var k = obj2key(array[i], keys);
  494. if (!(k in hash)) {
  495. hash[k] = true;
  496. arr.push(array[i]);
  497. }
  498. }
  499. return arr;
  500. }
  501. }
  502. })
  503. })
  504. // #endif
  505. },
  506. edit_detail(e) {
  507. this.request({
  508. url: "funeng/edit_detail",
  509. data: {
  510. card_num: this.card_num,
  511. },
  512. }).then(res => {
  513. console.log(res, "res")
  514. if (res.code === '200') {
  515. this.info = res.data;
  516. // this.img_file = res.data.img_file;
  517. this.description= res.data.description;
  518. this.arr = res.data.funeng;
  519. this.url = res.data.url;
  520. this.mid_img = res.data.mid_img;
  521. this.mid_type = res.data.mid_type;
  522. this.mid_state = res.data.mid_state;
  523. this.mid_title = res.data.mid_title;
  524. this.hj_state=res.data.hj_state;
  525. this.is_exchange=res.data.is_exchange;
  526. var qr_arr= res.data.urls;
  527. this.moshi = res.data.moshi;
  528. this.moshi_type=res.data.moshi_type;
  529. this.ruleArr=res.data.rule_arr;
  530. console.log(this.moshi_type,"moshi_type")
  531. if(this.moshi==2){
  532. if(this.moshi_type==2){
  533. var a = []
  534. for(let i of res.data.rule_arr){
  535. a.push(i.type)
  536. }
  537. // 去除重复的数
  538. var b = []
  539. for (var i = 0; i < a.length; i++) {
  540. if (b.indexOf(a[i]) === -1) {
  541. b.push(a[i])
  542. }
  543. }
  544. this.level=b.join(",");
  545. this.powerpool_id=res.data.powerpool_id;
  546. }
  547. for(let i of res.data.powerpool){
  548. i.checked=true;
  549. }
  550. this.list_way=res.data.powerpool;
  551. }
  552. for(let i in qr_arr){
  553. if(qr_arr[i].pay_company==1){
  554. qr_arr[i].type=1;
  555. qr_arr[i].img="../../static/images/pay_wx.png";
  556. }
  557. if(qr_arr[i].pay_company==2){
  558. qr_arr[i].type=2;
  559. qr_arr[i].img="../../static/images/pay_ali.png";
  560. }
  561. if(qr_arr[i].pay_company==5){
  562. qr_arr[i].type=5;
  563. qr_arr[i].img="../../static/images/qq.png";
  564. }
  565. if(qr_arr[i].pay_company==3||qr_arr[i].pay_company==4){
  566. qr_arr[i].type=3;
  567. qr_arr[i].img="../../static/images/pay_jh.png";
  568. }
  569. }
  570. this.qr_arr=qr_arr;
  571. this.allmuban();
  572. }
  573. }).catch((res) => {});
  574. },
  575. bangCode(e) {
  576. console.log(e, "bangCode")
  577. // #ifdef MP-WEIXIN
  578. uni.scanCode({
  579. success: (res) => {
  580. console.log('条码类型:' + res.scanType);
  581. console.log('条码内容:' + res.result);
  582. var params = (() => {
  583. var search = res.result; //获取location的search属性,保存在search中
  584. var params = {}; //创建空对象params
  585. if (search != "") { //如果search不是空字符串
  586. search.slice(1).split("?").forEach( //?username=zhangdong&pwd=123456;//search去开头?,按&切割为数组,forEach
  587. function(val) {
  588. var arr = val.split("="); //将当前元素值按=切割,保存在arr中
  589. params[arr[0]] = arr[1]; //向params中添加一个元素,属性名为arr[0],值为arr[1]
  590. }
  591. );
  592. }
  593. return params; //返回params
  594. })();
  595. this.result = params.card_num;
  596. this.https(1)
  597. }
  598. });
  599. // #endif
  600. // #ifdef H5
  601. getWXSign().then(res => {
  602. console.log('wx_getLocation');
  603. this.$wx.scanQRCode({
  604. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  605. scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  606. success: (res) => {
  607. console.log(res, "qrCode")
  608. // this.result = res.resultStr;
  609. var params = (() => {
  610. var search = res.resultStr; //获取location的search属性,保存在search中
  611. var params = {}; //创建空对象params
  612. if (search != "") { //如果search不是空字符串
  613. search.slice(1).split("?").forEach( //?username=zhangdong&pwd=123456;//search去开头?,按&切割为数组,forEach
  614. function(val) {
  615. var arr = val.split("="); //将当前元素值按=切割,保存在arr中
  616. params[arr[0]] = arr[1]; //向params中添加一个元素,属性名为arr[0],值为arr[1]
  617. }
  618. );
  619. }
  620. return params; //返回params
  621. })();
  622. this.result = params.card_num;
  623. this.https(1)
  624. }
  625. })
  626. })
  627. // #endif
  628. },
  629. ScCode(e) {
  630. this.https(2)
  631. },
  632. https(type) {
  633. let arr = this.arr,
  634. qr_arr=this.qr_arr,
  635. ul=[],
  636. way_id = [],
  637. way_power = [];
  638. for (let i of arr) {
  639. way_id.push(i.id);
  640. way_power.push(i.way_power)
  641. }
  642. for (let i of qr_arr) {
  643. ul.push(i.url);
  644. }
  645. var powerpool_id ="";
  646. if(this.moshi_type==1){
  647. var powerpool_arr = [];
  648. for (let i of this.list_way) {
  649. if (i.checked) {
  650. powerpool_arr.push(i.id);
  651. }
  652. }
  653. powerpool_id=powerpool_arr.join(",");
  654. }else{
  655. powerpool_id=this.powerpool_id;
  656. }
  657. if (way_power.length <= 0) {
  658. uni.showToast({
  659. title: "场景为空",
  660. icon: 'none'
  661. })
  662. return
  663. }
  664. if (!ul) {
  665. uni.showToast({
  666. title: "收款图片为空",
  667. icon: 'none'
  668. })
  669. return
  670. }
  671. let data = {
  672. token: uni.getStorageSync("token"),
  673. type: 1,
  674. paycode_type: 1,
  675. // 1图片2链接
  676. // paycode_img: this.img_file,
  677. // img_file: this.img_file,
  678. paycode_num:1,
  679. url_arr:ul.join(","),
  680. url:ul.join(","),
  681. way_id: way_id.join(","),
  682. way_power: way_power.join(","),
  683. save_type: type,
  684. qrcode: this.result,
  685. hj_state:this.hj_state,
  686. mid_state: this.mid_state,
  687. mid_title:this.mid_title,
  688. mid_type:this.Advertising[this.Adver_index].id,
  689. mid_img: this.Advertising[this.Adver_index].id == "0" ? this.mid_img : this.Advertising[this.Adver_index].thumb,
  690. description: this.description,
  691. is_exchange:this.is_exchange,
  692. moshi:this.moshi,
  693. moshi_type:this.moshi_type,
  694. powerpool_id:powerpool_id,
  695. level:this.level,
  696. rule:this.rule,
  697. }
  698. let url;
  699. this.card_num ? (data.code = this.info.code, url = "funeng/save_edit") : url = "funeng/paycode";
  700. //请求验证码
  701. this.request({
  702. url,
  703. data,
  704. }).then(res => {
  705. console.log(res, "res")
  706. if (res.code === '200') {
  707. this.card_num ? (
  708. uni.showToast({
  709. title: "设置成功",
  710. icon: 'none'
  711. }),
  712. setTimeout(() => {
  713. uni.navigateBack({
  714. delta: 1
  715. })
  716. }, 2e3)
  717. ) : (
  718. uni.showToast({
  719. title: "生成成功",
  720. icon: 'none'
  721. }),
  722. uni.redirectTo({
  723. url: "code?type=1" + '&card_num=' + res.data.card_num
  724. })
  725. )
  726. }
  727. }).catch((res) => {
  728. uni.showToast({
  729. title: res.message,
  730. icon: 'none'
  731. })
  732. });
  733. },
  734. ChooseImage(e) {
  735. console.log(e, "rrr")
  736. let type = e.currentTarget.dataset.type;
  737. uni.chooseImage({
  738. count: 1, //默认9
  739. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  740. sourceType: ['album'], //从相册选择
  741. success: (res) => {
  742. res.tempFilePaths.forEach((v, i) => {
  743. console.log(v)
  744. this.Upload({
  745. url: "Spread/upload_img",
  746. data: {
  747. url: v,
  748. type: type == 1 ? 1 : 0,
  749. token: uni.getStorageSync("token"),
  750. }
  751. }).then(res => {
  752. if (type == 1) {
  753. this.img_file = res.file
  754. this.url = res.url
  755. } else {
  756. this.mid_img = res.file
  757. }
  758. console.log(res, "res")
  759. }).catch(err => {
  760. console.log(err, "err")
  761. uni.showToast({
  762. title: err.message,
  763. icon: 'none'
  764. })
  765. });
  766. })
  767. },
  768. });
  769. },
  770. }
  771. }
  772. </script>
  773. <style>
  774. .qr_content {
  775. padding: 0 40rpx;
  776. }
  777. .qr_content_img {
  778. display: inline-block;
  779. position: relative;
  780. }
  781. .qr_content_img .qr_content_img_li {
  782. margin-left: 20rpx;
  783. width: 120rpx;
  784. height: 120rpx;
  785. }
  786. .qr_content_img_del {
  787. width: 40rpx;
  788. height: 40rpx;
  789. position: absolute;
  790. top: 0;
  791. right: 0;
  792. }
  793. .tr {
  794. text-align: right;
  795. }
  796. .pdr-20 {
  797. padding-right: 20rpx;
  798. }
  799. .item {
  800. padding: 32rpx 40rpx;
  801. }
  802. .upimg {
  803. width: 126rpx;
  804. height: 126rpx;
  805. }
  806. .add-home {
  807. color: #FFFFFF;
  808. width: 126rpx;
  809. height: 54rpx;
  810. background: linear-gradient(315deg, #3387ff 2%, #569bff 99%);
  811. border-radius: 8rpx;
  812. box-shadow: 0px 0px 8rpx 0px rgba(51, 135, 255, 0.2);
  813. }
  814. .item-bg {
  815. width: 670rpx;
  816. /* height: 298rpx; */
  817. background: #f6f8fe;
  818. border-radius: 12rpx;
  819. margin: 0 auto;
  820. font-size: 28rpx;
  821. font-family: PingFang SC, PingFang SC-Regular;
  822. font-weight: 400;
  823. color: #333333;
  824. padding: 36rpx 32rpx;
  825. }
  826. .item-del {
  827. width: 40rpx;
  828. height: 40rpx;
  829. }
  830. .mar64 {
  831. margin-bottom: 64rpx;
  832. }
  833. .item-bg .mar64:last-child {
  834. margin-bottom: 0rpx;
  835. }
  836. .hg200rpx {
  837. height: 100rpx;
  838. }
  839. .mgr57 {
  840. margin-bottom: 57rpx;
  841. }
  842. .item-bg-32 {
  843. margin-right: 32rpx;
  844. }
  845. .qrupimg {
  846. width: 80rpx;
  847. height: 80rpx;
  848. }
  849. .tips{
  850. font-size: 26rpx;
  851. color: #999;
  852. }
  853. </style>