product-machine-transfer.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>兑换券划拨-产品中心-创业帮</title>
  6. <meta name="keywords" content="兑换券划拨-产品中心-创业帮">
  7. <meta name="description" content="兑换券划拨-产品中心-创业帮">
  8. <meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,shrink-to-fit=no,user-scalable=no" name="viewport" viewport="cover">
  9. <meta name="apple-mobile-web-app-capable" content="yes">
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
  11. <meta content="telephone=no" name="format-detection">
  12. <meta content="email=no" name="format-detection">
  13. <meta name="apple-mobile-web-app-title" content="兑换券划拨-产品中心-创业帮">
  14. <meta http-equiv="Cache-Control" content="no-siteapp">
  15. <link rel="stylesheet" href="./static/css/main.css">
  16. <style>
  17. .machine-list .van-cell__value{
  18. flex:.4;
  19. }
  20. .mall-bottom{padding:0 .3733rem;height:54px;}
  21. .mall-bottom button{border-radius:999px !important; height:80% !important;}
  22. .ismeng{font-size:4px;border:.5px solid #FFD6D6;color:#FF7D7D;padding:0 2px;margin-right:5px;}
  23. </style>
  24. </head>
  25. <body class="h100p pt0 pb0" style="padding-top:0;">
  26. <div class="machine-tag" id="app" v-cloak>
  27. <van-nav-bar class="user_rank_explan_title user_title_normal titlef16" left-arrow :title="'机具划拨-'+title" v-if="toptitleisshow" @click-left="goback" @click-right="dialoutrecord">
  28. <template #left><img src="./static/images/left.png" alt=""></template>
  29. <template #right>
  30. <div class="f12">划拨记录</div>
  31. </template>
  32. </van-nav-bar>
  33. <van-sticky v-cloak></van-sticky>
  34. <van-tabs v-model="active" swipeable animated @change="changetab">
  35. <van-tab class="bgcfff" :title="'电签兑换券(' + notUseCount + ')'">
  36. <div class="ovh-x" ref="wrapper2" v-if="active === 0">
  37. <van-pull-refresh v-model="refreshing" @refresh="onRefresh" :class="transactions.length === 0 ? 'isnodata':''" style="height:100%;">
  38. <van-list v-model="loading" :finished="finished" finished-text="没有更多数据了" @load="onLoad" :immediate-check="false">
  39. <van-cell class="alltransfer" title="全选" clickable @click="toggleSelectAll" style="position:sticky; top:0; z-index:999">
  40. <template #icon>
  41. <van-checkbox class="mr16" name="selectedNum" v-model="SelectedAll" checked-color="#ec5e3b"></van-checkbox>
  42. </template>
  43. <template #default>
  44. <div class="f12">已选{{result.length}}张</div>
  45. </template>
  46. </van-cell>
  47. <van-empty class="custom-image" image="./static/images/empty-img.png" description="暂无数据" v-if="transactions.length === 0"></van-empty>
  48. <van-checkbox-group v-model="result">
  49. <van-cell-group>
  50. <van-cell class="machine-list" v-for="item,index in transactions" clickable :key="index" value-class="f14 c333" @click="toggle(index,'')">
  51. <template #default>
  52. <div class="f14">{{item.Kind === 1 ? '电签兑换券' : '大机兑换券'}}</div>
  53. </template>
  54. <template #title>
  55. <div class="f14 c333"><span class="ismeng" v-if="item.IsLeader === 1">盟</span><span class="vm">兑换码:</span><span class="vm pr6" :id="'sn'+index">{{item.ExchangeCode}}</span><span class="dib vm" :data-clipboard-text="item.ExchangeCode" data-clipboard-action="copy" :data-clipboard-target="'#sn'+index" :ref="'copy'+index" @click.stop="copySN(index)" @mouseenter="copySN(index)"><img src="./static/images/icon-copy.png" alt="" width="14" height="14"></span></div>
  56. </template>
  57. <template #icon>
  58. <van-checkbox class="mr16" :name="item" ref="checkboxes" checked-color="#ec5e3b"></van-checkbox>
  59. </template>
  60. <template #label></template>
  61. </van-cell>
  62. </van-cell-group>
  63. </van-checkbox-group>
  64. </van-list>
  65. </van-pull-refresh>
  66. </div>
  67. </van-tab>
  68. <van-tab class="bgcfff" :title="'大机兑换券(' + notUseCount2 + ')'">
  69. <div class="ovh-x" ref="wrapper2" v-if="active === 1">
  70. <van-pull-refresh v-model="refreshing" @refresh="onRefresh" :class="transactions.length === 0 ? 'isnodata':''" style="height:100%;">
  71. <van-list v-model="loading" :finished="finished" finished-text="没有更多数据了" @load="onLoad" :immediate-check="false">
  72. <van-cell class="alltransfer" title="全选" clickable @click="toggleSelectAll" style="position:sticky; top:0; z-index:999">
  73. <template #icon>
  74. <van-checkbox class="mr16" name="selectedNum" v-model="SelectedAll" checked-color="#ec5e3b"></van-checkbox>
  75. </template>
  76. <template #default>
  77. <div class="f12">已选{{result.length}}张</div>
  78. </template>
  79. </van-cell>
  80. <van-empty class="custom-image" image="./static/images/empty-img.png" description="暂无数据" v-if="transactions.length === 0"></van-empty>
  81. <van-checkbox-group v-model="result">
  82. <van-cell-group>
  83. <van-cell class="machine-list" v-for="item,index in transactions" clickable :key="index" value-class="f14 c333" @click="toggle(index,'')">
  84. <template #default>
  85. <div class="f14">{{item.Kind === 1 ? '电签兑换券' : '大机兑换券'}}</div>
  86. </template>
  87. <template #title>
  88. <div class="f14 c333"><span class="ismeng" v-if="item.IsLeader === 1">盟</span><span class="vm">兑换码:</span><span class="vm pr6" :id="'sn'+index">{{item.ExchangeCode}}</span><span class="dib vm" :data-clipboard-text="item.ExchangeCode" data-clipboard-action="copy" :data-clipboard-target="'#sn'+index" :ref="'copy'+index" @click.stop="copySN(index)" @mouseenter="copySN(index)"><img src="./static/images/icon-copy.png" alt="" width="14" height="14"></span></div>
  89. </template>
  90. <template #icon>
  91. <van-checkbox class="mr16" :name="item" ref="checkboxes" checked-color="#ec5e3b"></van-checkbox>
  92. </template>
  93. <template #label></template>
  94. </van-cell>
  95. </van-cell-group>
  96. </van-checkbox-group>
  97. </van-list>
  98. </van-pull-refresh>
  99. </div>
  100. </van-tab>
  101. </van-tabs>
  102. <van-popup v-model="checkscreenisshow" round position="bottom" :style="{ height: '50%' }" v-cloak>
  103. <div class="rel" style="height:95%;margin:16px;margin-bottom:0;">
  104. <div class="title mt8 pb16 c999">请选择活动类型</div>
  105. <div class="brandlistcard tc mb12" v-for="item,index in brandlist" :key="item.Id" :class="brandischeck === item.Id ? 'spbrandlistcard':''" @click="brandcheckbtn(item.Id)">{{item.Name}}</div>
  106. </div>
  107. </van-popup>
  108. <van-goods-action class="mall-bottom">
  109. <van-goods-action-button class="kxs-btn" type="default" color="#FFD500" style="color:#333;" text="划拨" @click="transfer"></van-goods-action-button>
  110. </van-goods-action>
  111. <van-overlay :show="nextshow" @click="closenextshow">
  112. <div class="unbindpop cm">
  113. <div class="unbindcard tc" @click.stop>
  114. <div class="f12 tc c666 title">总共划拨{{result.length}}台,请仔细核对SN号及姓名是否正确</div>
  115. <input type="text" v-model="createercode" placeholder="请输入创客编号" @focus="inputbtn">
  116. <div class="f12 tc c333 title" v-if="createrinfo.RealName !== ''">姓名:{{createrinfo.RealName}}</div>
  117. <div class="nextbutton cfff cm mt16 f14" @click="diaolignextbtn" style="color:#333;">{{createrinfo.RealName === ''? '下一步' : '确认无误划拨'}}</div>
  118. </div>
  119. </div>
  120. </van-overlay>
  121. </div>
  122. <script src="./static/js/clipboard.min.js"></script>
  123. <script src="./static/js/klm-vv.min.js"></script>
  124. <script src="./static/js/appfunc.min.js"></script>
  125. <script src="./static/js/klm-axios-config.js"></script>
  126. <script src="./static/js/publicfn.js"></script>
  127. <script>
  128. function OnStart(){
  129. if(PublicLib.getCookieInfo('isallbacktransfer') === 'true'){
  130. PublicLib.putCookieInfo('isallbacktransfer', '');
  131. //- app.pageinfo.PageNum = 1;
  132. //- app.getmachinelist('refresh');
  133. };
  134. };
  135. // 通过 CDN 引入时不会自动注册 Lazyload 组件
  136. // 可以通过下面的方式手动注册
  137. Vue.use(vant.Lazyload);
  138. // 在 #app 标签下渲染一个按钮组件
  139. let app = new Vue({
  140. el: '#app',
  141. data() {
  142. return {
  143. active:0,
  144. loading: false,
  145. finished: false,
  146. refreshing:false,
  147. issetcount:false,
  148. isnodata:false,
  149. toptitleisshow:false,
  150. nextshow:false,
  151. changeactiveid:'',
  152. checkscreenisshow:false,
  153. createercode:'',
  154. copyBtn: {},
  155. result: [],
  156. productId:'',
  157. brandlist:[
  158. {Id:'',Name:'全部'}
  159. ],
  160. brandchecklist:[
  161. ],
  162. brandischeck:'',
  163. transactions: [
  164. ],
  165. pageinfo:{
  166. PageSize:20,
  167. PageNum:1
  168. },
  169. loading: false,
  170. finished: false,
  171. refreshing: false,
  172. createrinfo:{
  173. RealName:'',
  174. Id:'',
  175. },
  176. SelectedAll: false,
  177. title:'',
  178. is200:false,
  179. notUseCount:0,
  180. usedCount:0,
  181. notUseCount2:0,
  182. usedCount2:0,
  183. ischecked:false,
  184. };
  185. },
  186. created() {
  187. this.productId = PublicLib.getCookieInfo('productMachineId');
  188. this.title=PublicLib.getCookieInfo('productMachineType');
  189. this.toptitleisshow = toptitleisshow;
  190. if(this.productId === '1' || this.productId === '2'){
  191. this.is200 = true;
  192. }else{
  193. this.is200 === false
  194. };
  195. PublicLib.SetTitle({Title:'机具券划拨-'+ PublicLib.getCookieInfo('productMachineType')});
  196. this.getexchangelist('refresh');
  197. },
  198. beforeUpdate(){
  199. this.$nextTick(() => {
  200. this.$refs.wrapper2.style.height = `${document.documentElement.clientHeight - 95}px`;
  201. });
  202. },
  203. methods: {
  204. changetab(){
  205. const that = this;
  206. that.finished = false;
  207. that.SelectedAll = false;
  208. that.ischecked = true;
  209. that.result = [];
  210. that.transactions = [];
  211. that.pageinfo.PageNum = 1;
  212. that.getexchangelist('refresh');
  213. },
  214. onRefresh() {
  215. const that = this;
  216. that.pageinfo.PageNum = 1;
  217. // 清空列表数据
  218. that.finished = false;
  219. that.ischecked = true;
  220. //- that.transactions = [];
  221. that.SelectedAll = false; //下拉刷新时,清空全选状态
  222. // 重新加载数据
  223. // 将 loading 设置为 true,表示处于加载状态
  224. that.getexchangelist('refresh');
  225. },
  226. onLoad() {
  227. const that = this;
  228. if(that.ischecked){
  229. return;
  230. };
  231. that.pageinfo.PageNum += 1;
  232. that.getexchangelist();
  233. // 加载更多数据后,将全选状态清空
  234. if(that.pageinfo.PageNum !== 1){
  235. setTimeout(() => {
  236. if(that.result.length == that.transactions.length && that.transactions.length !== 0){
  237. that.SelectedAll = true;
  238. }else{
  239. that.SelectedAll = false;
  240. };
  241. }, 10);
  242. }else{
  243. that.SelectedAll = false;
  244. };
  245. },
  246. //- 全选按钮
  247. toggleSelectAll(){
  248. const that = this;
  249. that.SelectedAll = !that.SelectedAll;
  250. if(that.SelectedAll){
  251. that.result = that.transactions;
  252. }else{
  253. that.result = [];
  254. };
  255. },
  256. brandchangebtn(id){
  257. this.changeactiveid = id;
  258. },
  259. inputbtn(){
  260. this.createrinfo.RealName = '';
  261. },
  262. giveToast(str){
  263. vant.Toast(str);
  264. },
  265. copySN(index){
  266. const that = this;
  267. this.$nextTick(() => {
  268. that.copyBtn = new ClipboardJS(this.$refs['copy'+index][0]);
  269. const clipboard = that.copyBtn;
  270. clipboard.on('success', function(e) {
  271. that.giveToast('复制成功');
  272. });
  273. clipboard.on('error', function(e) {
  274. that.giveToast('复制失败,请手动选择复制!');
  275. });
  276. });
  277. },
  278. //- 全选反选
  279. toggle(index,type) {
  280. const that = this;
  281. if(type === '赠送机') return;
  282. this.$refs.checkboxes[index].toggle();
  283. setTimeout(() => {
  284. if(that.result.length == that.transactions.length){
  285. that.SelectedAll = true;
  286. }else{
  287. that.SelectedAll = false;
  288. };
  289. }, 10);
  290. },
  291. transfer(){
  292. if(PublicLib.getCookieInfo('userId') === '124473'){
  293. return tips('账号异常,请联系客服');
  294. };
  295. if(this.result.length === 0){
  296. return tips('请至少选择1台机具!');
  297. };
  298. const ischeck = this.result.find(item=>{
  299. //- console.log(item.PosSnType)
  300. return item.PosSnType === '赠送机';
  301. });
  302. if(ischeck){
  303. return tips('赠送机不可划拨,请重新选择')
  304. };
  305. this.nextshow = true;
  306. },
  307. closenextshow(){
  308. this.nextshow = false;
  309. this.createercode = '';
  310. this.createrinfo.RealName = '';
  311. },
  312. onClickButton() {
  313. PublicLib.putCookieInfo('machinesearchType', 'whole');
  314. PublicLib.Goto({Url:'product-machine-all-transfer'});
  315. },
  316. goback(){
  317. PublicLib.GoBack({Level:1});
  318. },
  319. gosearch(){
  320. PublicLib.putCookieInfo('machinesearchType', 'unbind');
  321. PublicLib.Goto({Url:'product-machine-search'});
  322. },
  323. //- 品牌筛选
  324. brandcheckbtn(id){
  325. this.brandischeck = id;
  326. this.checkscreenisshow = false;
  327. //- this.transactions = [];
  328. this.pageinfo.PageNum = 1;
  329. this.getmachinelist('refresh');
  330. },
  331. async getexchangelist(type = 'onload'){
  332. const that = this;
  333. const Kind = that.active === 0 ? 1 : 2;
  334. const UserId = PublicLib.getCookieInfo('userId');
  335. const res = await getRequest('api/v1/pos/poscoupons/exchangecoupons?t='+Math.random(6),JSON.stringify({...that.pageinfo,UserId,Kind}));
  336. if(res.status !== '1')return tips('兑换码列表获取失败!');
  337. if(res.data.length < that.pageinfo.PageSize) {
  338. that.finished = true;
  339. };
  340. if(type === 'refresh'){
  341. that.result = [];
  342. that.transactions = res.data;
  343. that.ischecked = false;
  344. that.refreshing = false;
  345. }else{
  346. that.transactions.push(...res.data);
  347. }
  348. // 设置loading为false,表示加载完毕,可再次加载数据
  349. that.loading = false;
  350. if(that.pageinfo.PageNum === 1){
  351. that.notUseCount = res.other.NotUseCount;
  352. that.notUseCount2 = res.other.NotUseCount2;
  353. };
  354. if(that.transactions.length === 0) {that.isnodata = true}else{that.isnodata = false};
  355. },
  356. diaolignextbtn:undebounce(async function(){
  357. if(this.createercode === '') return tips('请输入创客编号');
  358. if(this.createrinfo.RealName === '') {
  359. const res = await getRequest('api/v1/users/forcode?t='+Math.random(6),JSON.stringify({MakerCode:this.createercode}));
  360. if(res.status !== '1')return tips(res.info);
  361. this.createrinfo = res.data;
  362. } else{
  363. if(!this.createrinfo.RealName){
  364. return tips('请输入正确的创客编号!');
  365. };
  366. const CouponIds = this.result.map(item=>{
  367. return item.Id;
  368. }).join(',');
  369. //- 1:200 2:300
  370. const Kind = this.active === 0 ? 1 : 2;
  371. const UserId = PublicLib.getCookieInfo('userId');
  372. const res = await postRequest('/api/v1/pos/poscouponrecord/add?t='+Math.random(6),JSON.stringify({UserId,CouponIds,ToUserId:this.createrinfo.Id,Kind}));
  373. if(res.status === '-1' && res.info === '请输入正确的创客编号') return tips('请输入同一创客体系内的创客编码');
  374. if(res.status !== '1')return tips(res.info);
  375. tips('兑换券划拨申请提交成功!');
  376. this.nextshow = false;
  377. this.createrinfo = {RealName:'',Id:''};
  378. this.createercode = '';
  379. this.result.forEach(item=>{
  380. this.transactions.forEach((obj,index)=>{
  381. if(item.Id === obj.Id){
  382. this.transactions.splice(index,1);
  383. };
  384. });
  385. });
  386. //- this.transactions = [];
  387. this.result=[];
  388. this.SelectedAll = false;
  389. this.pageinfo.PageNum = 1;
  390. this.getexchangelist('refresh');
  391. }
  392. }),
  393. dialoutrecord(){
  394. if(this.active === 0){
  395. PublicLib.putCookieInfo('transkind','true');
  396. }else{
  397. PublicLib.putCookieInfo('transkind','');
  398. };
  399. PublicLib.Goto({Url:'product-profit-dialoutrecord-trans'});
  400. }
  401. }
  402. });
  403. </script>
  404. </body>
  405. </html>