HM-dragSorts.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. <template>
  2. <view class="HM-drag-sort" :style="{'height': ListHeight+'px','background-color': listBackgroundColor}">
  3. <!-- 拖拽中显示的行 -->
  4. <view class="rowBox-shadow" id="shadowRowBox">
  5. <view class="hm-row-shadow move" id="shadowRow">
  6. <view class="modules">
  7. <!-- 内容 -->
  8. <view class="row-content">
  9. <view class="row" :style="{'height': rowHeight+'px'}">
  10. <image v-if="shadowRow.icon" class="icon" :src="shadowRow.icon"></image>
  11. <text class="text">{{shadowRow.name}}</text>
  12. </view>
  13. </view>
  14. <!-- 拖拽图标 -->
  15. <view class="drag-content">
  16. <view class="drag-icon" :style="{'height': rowHeight+'px'}">
  17. <text class="iconfont icon-drag"></text>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <!-- 拖拽列表 -->
  24. <scroll-view class="color scroll-view" :id="'scrollView_'+guid" :scroll-y="true"
  25. :style="{'height': ListHeight+'px'}" :scroll-top="scrollViewTop" @scroll="drag.scroll"
  26. :scroll-with-animation="scrollAnimation">
  27. <view class="list">
  28. <view v-for="(row,index) in dragList" :key="row.HMDrag_id" class="rowBox ani">
  29. <!-- 注意,这里的style只有在行首次渲染出来才有效,后面拖动列表,style会被wxs修改,这里的style就不会再生效了 -->
  30. <view class="hm-row" :style="{'transform': 'translate3d(0,' + (row.HMDrag_sort-index)*100 + '%,-1px)'}" :data-sort="row.HMDrag_sort" :data-id="row.HMDrag_id" :id="row.HMDrag_id">
  31. <view class="modules">
  32. <!-- 内容 -->
  33. <view class="row-content">
  34. <view class="row" @tap="triggerClick(row.HMDrag_sort, row)" :style="{'height': rowHeight+'px'}">
  35. <image v-if="row.icon" class="icon" :src="row.icon"></image>
  36. <text class="text">{{row.name}}</text>
  37. </view>
  38. </view>
  39. <!-- 拖拽图标 -->
  40. <view class="drag-content" :data-id="row.HMDrag_id" @touchstart="drag.touchstart"
  41. @touchmove="drag.touchmove" @touchend="drag.touchend">
  42. <view class="drag-icon" :style="{'height': rowHeight+'px'}">
  43. <text class="iconfont icon-drag"></text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </scroll-view>
  51. <!-- 数据跳板 -->
  52. <view id="dataView" style="display: none !important;" :data-guid="guid" :prop="wxsDataStr" :change:prop="drag.receiveData">触发wxs跳板,请勿删除</view>
  53. <!-- #ifdef APP-VUE || H5 -->
  54. <view style="display: none !important;" :prop="scrollCommand" :change:prop="renderjs.runCommand">触发renderjs跳板,请勿删除</view>
  55. <!-- #endif -->
  56. </view>
  57. </template>
  58. <script src="./drag.wxs" module="drag" lang="wxs"></script>
  59. <script module="renderjs" lang="renderjs">
  60. // APP or H5端 renderjs 实现拖拽中的自动滚动列表
  61. export default {
  62. data() {
  63. return {
  64. e: null,
  65. ScrollView: null,
  66. }
  67. },
  68. methods: {
  69. runCommand(e) {
  70. if (e == null) {
  71. return
  72. }
  73. this.e = e;
  74. this.getScrollView(document.getElementById('scrollView_' + this.e.guid))
  75. window.cancelAnimationFrame(this.AnimationFrameID);
  76. this.AnimationFrameID = window.requestAnimationFrame(this.Animation);
  77. if (e.command == "stop") {
  78. window.cancelAnimationFrame(this.AnimationFrameID);
  79. return;
  80. }
  81. },
  82. Animation() {
  83. if (this.e.command == "stop") {
  84. window.cancelAnimationFrame(this.AnimationFrameID);
  85. return;
  86. }
  87. // 计算最大滚动高度
  88. let maxScrollTop = this.e.rowLength * this.e.rowHeight - this.e.ListHeight;
  89. if (this.e.command == "up") {
  90. this.ScrollView.scrollTop -= 3
  91. } else if (this.e.command == "down") {
  92. this.ScrollView.scrollTop += 3;
  93. }
  94. if (this.ScrollView.scrollTop < 0) {
  95. this.ScrollView.scrollTop = 0;
  96. window.cancelAnimationFrame(this.AnimationFrameID);
  97. }
  98. if (this.ScrollView.scrollTop > maxScrollTop) {
  99. this.ScrollView.scrollTop = maxScrollTop;
  100. window.cancelAnimationFrame(this.AnimationFrameID);
  101. }
  102. this.AnimationFrameID = window.requestAnimationFrame(this.Animation);
  103. },
  104. getScrollView(DOM) {
  105. if (this.ScrollView != null) {
  106. return this.ScrollView;
  107. }
  108. let styleStr = DOM.getAttribute('style');
  109. if (DOM.className == 'uni-scroll-view' && styleStr != null && styleStr.indexOf('overflow') > -1 && styleStr
  110. .indexOf(
  111. 'auto') > -1) {
  112. this.ScrollView = DOM;
  113. return DOM;
  114. } else {
  115. this.getScrollView(DOM.firstChild);
  116. }
  117. }
  118. }
  119. }
  120. </script>
  121. <script>
  122. /**
  123. * 拖拽排序组件 HM-dragSort
  124. * @description 拖拽排序组件 HM-dragSort
  125. * @property {ObjectArray} list = [] 列表数据,数据格式[{"name": "花呗","icon": "/static/img/1.png",}]
  126. * @property {Boolean} feedbackGenerator = [true|false] 是否拖动触感反馈
  127. * @property {Boolean} longTouch = [true|false] 是否长按拖动
  128. * @property {Boolean} autoScroll = [true|false] 是否拖拽至边缘自动滚动列表
  129. * @property {Number} longTouchTime = [] 选填,触发长按时长,单位:ms,默认350ms,不支持微信小程序
  130. * @property {Number} listHeight = 0 选填,可拖动列表整体的高度,单位:px,默认等于窗口高度
  131. * @property {Number} rowHeight = 44 选填,行高,单位:px,默认44px
  132. * @property {String} listBackgroundColor 选填,列表底色,注意是列表的底色,不是行的底色,默认#FFFFFF
  133. * @event {Function} change 行位置发生改变时触发事件 返回值:{index:'原始下标',moveTo:'被拖动到的下标',moveRow:'拖动行数据'}
  134. * @event {Function} confirm 拖拽结束且行位置发生了改变触发事件 返回值:{index:'原始下标',moveTo:'被拖动到的下标',moveRow:'拖动行数据',list:'整个列表拖动后的数据'}
  135. */
  136. export default {
  137. name: 'HM-dragSort',
  138. data() {
  139. return {
  140. guid: "",
  141. isAppH5: true, //是否APPH5 无需手动配置
  142. shadowRow: {}, // 存放被拖拽行数据
  143. // 列表数据
  144. dragList: [],
  145. ListHeight: this.listHeight, // scroll-view列表高度
  146. // 控制滑动
  147. scrollViewTop: 0, // 滚动条位置
  148. scrollCommand: null, //传递renderjs数据
  149. isHoldTouch: false, //是否正在拖拽
  150. isScrolling: false, //是否正在滚动视图
  151. scrollAnimation: false, //滚动动画 在微信端开启
  152. scrollTimer: null, //定时器-控制滚动 微信小程序端使用 实现类似requestAnimationFrame效果
  153. wxsDataObj: [],
  154. wxsDataStr: "[]"
  155. }
  156. },
  157. // #ifdef VUE3
  158. emits: ['change', 'confirm'],
  159. // #endif
  160. props: {
  161. //是否开启拖动震动反馈
  162. feedbackGenerator: {
  163. value: Boolean,
  164. default: true
  165. },
  166. // 是否开启长按拖动
  167. longTouch: {
  168. value: Boolean,
  169. default: false
  170. },
  171. autoScroll: {
  172. value: Boolean,
  173. default: true
  174. },
  175. longTouchTime: {
  176. value: Number,
  177. default: 300
  178. },
  179. // 列表数据
  180. list: {
  181. value: Array,
  182. default: []
  183. },
  184. // 行高度 默认44行高
  185. rowHeight: {
  186. value: Number,
  187. default: 44
  188. },
  189. // 组件高度 默认windowHeight满屏
  190. listHeight: {
  191. value: Number,
  192. default: 0
  193. },
  194. listBackgroundColor: {
  195. value: String,
  196. default: "#fff"
  197. }
  198. },
  199. watch: {
  200. longTouch(val) {
  201. // #ifdef VUE3
  202. if (!val) {
  203. console.error('vue3目前仅支持长按拖拽!');
  204. }
  205. // #endif
  206. this.pushWxsData('longTouch', val);
  207. },
  208. longTouchTime(val) {
  209. this.pushWxsData('longTouchTime', val);
  210. },
  211. feedbackGenerator(val) {
  212. this.pushWxsData('feedbackGenerator', val);
  213. },
  214. autoScroll(val) {
  215. this.pushWxsData('autoScroll', val);
  216. },
  217. list: {
  218. handler(val) {
  219. this.initList(val); //数据变化重新初始化list
  220. },
  221. immediate: true,
  222. deep: true
  223. },
  224. listHeight: {
  225. handler(val) {
  226. this.ListHeight = val;
  227. this.pushWxsData('ListHeight', this.ListHeight);
  228. },
  229. immediate: true
  230. }
  231. },
  232. mounted() {
  233. this.guid = this.getGuid();
  234. const res = uni.getSystemInfoSync();
  235. // #ifdef MP-WEIXIN
  236. let state = this.compareVersion(res.hostVersion, '2.14.2');
  237. if (state < 0) {
  238. console.error('当前微信基础库:' + res.hostVersion + ',HM-dragSorts组件仅支持微信基础库2.14.2+,请切换基础库!');
  239. }
  240. this.scrollAnimation = true;
  241. this.isAppH5 = false;
  242. // #endif
  243. if (this.listHeight == 0) {
  244. this.ListHeight = res.windowHeight;
  245. // #ifdef VUE3
  246. // vue3 要减去导航栏和状态栏高度
  247. if (res.windowHeight == res.screenHeight) {
  248. this.ListHeight = res.windowHeight - 45 - res.statusBarHeight;
  249. }
  250. // #endif
  251. }
  252. this.pushWxsData('isAppH5', this.isAppH5);
  253. this.pushWxsData('ListHeight', this.ListHeight);
  254. this.pushWxsData('longTouch', this.longTouch);
  255. },
  256. methods: {
  257. getGuid() {
  258. function S4() {
  259. return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
  260. }
  261. return (S4() + S4() + "_" + S4() + "_" + S4() + "_" + S4() + "_" + S4() + S4() + S4());
  262. },
  263. initList() {
  264. let tmpList = JSON.parse(JSON.stringify(this.list));
  265. for (let i = 0, len = tmpList.length; i < len; i++) {
  266. // 组件内赋予临时id和sort
  267. if (!tmpList[i].hasOwnProperty('HMDrag_id')) {
  268. tmpList[i].HMDrag_id = 'HMDragId_' + this.getGuid();
  269. }
  270. tmpList[i].HMDrag_sort = i;
  271. }
  272. if (this.dragList.length > 0) {
  273. setTimeout(() => {
  274. this.dragList.splice(0, this.dragList.length, ...tmpList);
  275. }, 50)
  276. } else {
  277. this.dragList = JSON.parse(JSON.stringify(tmpList));
  278. }
  279. this.pushWxsData('lastInitTime', (new Date()).valueOf());
  280. },
  281. loadShadowRow(e) {
  282. this.shadowRow = this.getMoveRow(e.rowSort);
  283. },
  284. //兼容微信小程序震动
  285. vibrate() {
  286. uni.vibrateShort()
  287. },
  288. // 控制自动滚动视图
  289. pageScroll(e) {
  290. // 滚动 up-上滚动 down-下滚动
  291. if (e.command == "up" || e.command == "down") {
  292. if (!this.isHoldTouch) {
  293. this.isHoldTouch = true;
  294. this.scrollViewTop = e.scrollTop;
  295. }
  296. if (this.isScrolling) {
  297. return;
  298. };
  299. this.isScrolling = true;
  300. if (this.isAppH5) {
  301. // APP端和H5端 执行renderjs的滚动
  302. e.ListHeight = this.ListHeight;
  303. e.rowHeight = this.rowHeight;
  304. e.rowLength = this.dragList.length;
  305. this.scrollCommand = e;
  306. return;
  307. }
  308. // 微信小程序执行以下逻辑
  309. this.scrollTimer != null && clearInterval(this.scrollTimer);
  310. let maxHeight = this.rowHeight * this.dragList.length + 1 - this.ListHeight;
  311. let runTick = true;
  312. // 逻辑层传递到视图层需要时间,可能会出现滚动不流畅现象
  313. this.scrollTimer = setInterval(() => {
  314. if (!runTick) {
  315. return;
  316. }
  317. this.runScroll(e.command, maxHeight);
  318. runTick = false;
  319. this.$nextTick(function() {
  320. runTick = true;
  321. })
  322. }, 16.6)
  323. }
  324. // 停止滚动
  325. if (e.command == "stop") {
  326. // #ifdef APP-PLUS || H5
  327. // 停止指定传递到renderjs
  328. this.scrollCommand = e;
  329. // #endif
  330. this.isScrolling && this.stopScroll();
  331. }
  332. },
  333. // 微信端的滚动
  334. runScroll(command, maxHeight) {
  335. if (command == "up") {
  336. this.scrollViewTop -= 5
  337. }
  338. if (command == "down") {
  339. this.scrollViewTop += 5;
  340. }
  341. if (this.scrollViewTop < 0) {
  342. this.scrollViewTop = 0;
  343. clearInterval(this.scrollTimer);
  344. }
  345. if (this.scrollViewTop > maxHeight) {
  346. this.scrollViewTop = maxHeight;
  347. clearInterval(this.scrollTimer);
  348. }
  349. },
  350. //停止滚动
  351. stopScroll() {
  352. this.scrollTimer != null && clearInterval(this.scrollTimer);
  353. this.isScrolling = false;
  354. this.scrollingtop = 0;
  355. },
  356. //
  357. getMoveRow(HMDrag_sort) {
  358. for (var i = 0, len = this.dragList.length; i < len; i++) {
  359. if (this.dragList[i].HMDrag_sort == HMDrag_sort) {
  360. return JSON.parse(JSON.stringify(this.dragList[i]));
  361. }
  362. }
  363. },
  364. //
  365. triggerClick(index, row) {
  366. var tmpRow = JSON.parse(JSON.stringify(row));
  367. // 清除临时id和sort
  368. delete tmpRow.HMDrag_id;
  369. delete tmpRow.HMDrag_sort;
  370. this.$emit('onclick', {
  371. index: index,
  372. row: JSON.parse(JSON.stringify(tmpRow))
  373. });
  374. },
  375. change(e) {
  376. e.moveRow = this.getMoveRow(e.index);
  377. // 清除组件临时赋予的id
  378. delete e.moveRow.HMDrag_id;
  379. delete e.moveRow.HMDrag_sort;
  380. this.$emit('change', e);
  381. },
  382. sort(e) {
  383. this.stopScroll();
  384. this.isHoldTouch = false;
  385. let moveRow = this.getMoveRow(e.index);
  386. // 检测清除临时id和sort
  387. delete moveRow.HMDrag_id;
  388. delete moveRow.HMDrag_sort;
  389. let list = JSON.parse(JSON.stringify(this.dragList));
  390. let tmpList = [];
  391. for (let i = 0, len = list.length; i < len; i++) {
  392. // 检测清除临时id和sort
  393. delete list[i].HMDrag_id;
  394. delete list[i].HMDrag_sort;
  395. let index = e.sortArray[i];
  396. this.dragList[i].HMDrag_sort = index;
  397. tmpList[index] = list[i];
  398. }
  399. // 触发组件confirm 并传递数据
  400. this.$emit('confirm', {
  401. list: tmpList,
  402. index: e.index,
  403. moveTo: e.offset,
  404. moveRow: moveRow
  405. });
  406. },
  407. getNowList(){
  408. let list = JSON.parse(JSON.stringify(this.dragList));
  409. let tmpList = [];
  410. for (let i = 0, len = list.length; i < len; i++) {
  411. let tmpSotr = list[i].HMDrag_sort;
  412. tmpList[tmpSotr] = list[i];
  413. // 检测清除临时id和sort
  414. delete tmpList[tmpSotr].HMDrag_id;
  415. delete tmpList[tmpSotr].HMDrag_sort;
  416. }
  417. return tmpList;
  418. },
  419. splice() {
  420. let deleteIndex = arguments[0];
  421. let deleteLength = arguments[1];
  422. let len = arguments.length;
  423. let waitPushList = [];
  424. for (let i = 2; i < len; i++) {
  425. var newRow = arguments[i]
  426. newRow.HMDrag_id = 'HMDragId_' + this.getGuid();
  427. newRow.HMDrag_sort = deleteIndex+i-2;
  428. waitPushList.push(newRow);
  429. }
  430. let minDeleteSort = deleteIndex;
  431. let maxDeleteSort = deleteLength>0?deleteIndex+deleteLength-1:deleteIndex;
  432. let offsetSort = waitPushList.length - deleteLength;
  433. let deleteIndexArray = [];
  434. for (let i = this.dragList.length-1; i >=0; i--) {
  435. let row = this.dragList[i];
  436. let rowSort = row.HMDrag_sort;
  437. // 跳过
  438. if(rowSort<minDeleteSort){
  439. continue;
  440. }
  441. // 删除
  442. if(deleteLength>0 && rowSort >= minDeleteSort && rowSort <=maxDeleteSort){
  443. this.dragList.splice(i,1);
  444. continue;
  445. }
  446. if(offsetSort!=0 && rowSort>=maxDeleteSort){
  447. let newSort = rowSort + offsetSort;
  448. this.dragList[i].HMDrag_sort = newSort;
  449. }
  450. }
  451. this.dragList.push(...waitPushList);
  452. this.pushNewSort();
  453. let list = JSON.parse(JSON.stringify(this.dragList));
  454. let tmpList = this.getNowList();
  455. return tmpList;
  456. },
  457. push(){
  458. let len = arguments.length;
  459. let waitPushList = [];
  460. let startSotr = this.dragList.length;
  461. for (let i = 0; i < len; i++) {
  462. var newRow = arguments[i]
  463. newRow.HMDrag_id = 'HMDragId_' + this.getGuid();
  464. newRow.HMDrag_sort = startSotr+i;
  465. waitPushList.push(newRow);
  466. }
  467. this.dragList.push(...waitPushList);
  468. this.pushNewSort();
  469. let tmpList = this.getNowList();
  470. return tmpList;
  471. },
  472. unshit(){
  473. let len = arguments.length;
  474. let waitPushList = [];
  475. for (let i = 0; i < len; i++) {
  476. var newRow = arguments[i]
  477. newRow.HMDrag_id = 'HMDragId_' + this.getGuid();
  478. newRow.HMDrag_sort = i;
  479. waitPushList.push(newRow);
  480. }
  481. for (let i = this.dragList.length-1; i >=0; i--) {
  482. let row = this.dragList[i];
  483. let rowSort = row.HMDrag_sort;
  484. let newSort = rowSort + len;
  485. this.dragList[i].HMDrag_sort = newSort;
  486. }
  487. this.dragList.push(...waitPushList);
  488. this.pushNewSort();
  489. let tmpList = this.getNowList();
  490. return tmpList;
  491. },
  492. pushNewSort(){
  493. let sortArray=[];
  494. for (let i = 0,len = this.dragList.length; i<len; i++) {
  495. sortArray.push(this.dragList[i].HMDrag_sort);
  496. }
  497. this.pushWxsData('sortArray', sortArray);
  498. this.pushWxsData('lastInitTime', (new Date()).valueOf());
  499. },
  500. pushWxsData(key=null, val=null) {
  501. this.wxsDataObj.splice(0,8,['guid', this.guid],
  502. ['listLength', this.dragList.length],
  503. ['ListHeight', this.ListHeight],
  504. ['isAppH5', this.isAppH5],
  505. ['longTouch', this.longTouch],
  506. ['longTouchTime', this.longTouchTime],
  507. ['feedbackGenerator', this.feedbackGenerator],
  508. ['autoScroll', this.autoScroll]);
  509. let index = -1;
  510. let sotrArrayIndex = -1;
  511. for (let i = 0; i < this.wxsDataObj.length; i++) {
  512. if (this.wxsDataObj[i][0] == key) {
  513. index = i;
  514. break;
  515. }
  516. }
  517. if (index > -1) {
  518. this.wxsDataObj[index][1] = val;
  519. if(key == 'sortArray'){
  520. sotrArrayIndex = index;
  521. }
  522. } else {
  523. this.wxsDataObj.push([key, val]);
  524. if(key == 'sortArray'){
  525. sotrArrayIndex = this.wxsDataObj.length-1;
  526. }
  527. }
  528. if (this.guid == "") {
  529. return;
  530. }
  531. this.wxsDataStr = JSON.stringify(this.wxsDataObj);
  532. },
  533. compareVersion(v1, v2) {
  534. v1 = v1.split('.')
  535. v2 = v2.split('.')
  536. const len = Math.max(v1.length, v2.length)
  537. while (v1.length < len) {
  538. v1.push('0')
  539. }
  540. while (v2.length < len) {
  541. v2.push('0')
  542. }
  543. for (let i = 0; i < len; i++) {
  544. const num1 = parseInt(v1[i])
  545. const num2 = parseInt(v2[i])
  546. if (num1 > num2) {
  547. return 1
  548. } else if (num1 < num2) {
  549. return -1
  550. }
  551. }
  552. return 0
  553. }
  554. }
  555. }
  556. </script>
  557. <style lang="scss" scoped>
  558. //默认
  559. $row-background-color:#fff;
  560. $border-color :#c8c7cb;
  561. $shadow-color-moveing :rgba(0, 0, 0, 0.5);
  562. //Dark模式
  563. $Dark-row-background-color:#000;
  564. $Dark-border-color :#3d3d40;
  565. $Dark-shadow-color-moveing :rgba(0, 0, 0, 0.5);
  566. //字体图标 拖拽图标
  567. @font-face {
  568. font-family: "HM-DS-font";
  569. src: url('data:font/truetype;charset=utf-8;base64,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') format('truetype');
  570. }
  571. .iconfont {
  572. font-family: "HM-DS-font" !important;
  573. font-style: normal;
  574. &.icon-drag {
  575. &:before {
  576. content: "\e6e4";
  577. }
  578. }
  579. }
  580. // 定义颜色 start
  581. //默认颜色
  582. .color,
  583. .rowBox-shadow {
  584. &.scroll-view {
  585. border-bottom: 1rpx $border-color solid;
  586. border-top: 1rpx $border-color solid;
  587. }
  588. .hm-row-shadow,
  589. .hm-row {
  590. .modules {
  591. .row-content {
  592. .row {
  593. border-bottom: solid 1rpx $border-color;
  594. background-color: $row-background-color;
  595. }
  596. }
  597. .drag-content {
  598. .drag-icon {
  599. border-bottom: solid 1rpx $border-color;
  600. background-color: $row-background-color;
  601. }
  602. }
  603. }
  604. &.move {
  605. box-shadow: 0 1px 5px $shadow-color-moveing;
  606. }
  607. }
  608. }
  609. // 暗黑模式
  610. @media (prefers-color-scheme: dark) {
  611. //Dark模式
  612. .color .rowBox-shadow {
  613. &.scroll-view {
  614. border-bottom: 1rpx $Dark-border-color solid;
  615. border-top: 1rpx $Dark-border-color solid;
  616. }
  617. .hm-row-shadow,
  618. .hm-row {
  619. .modules {
  620. .row-content {
  621. .row {
  622. border-bottom: solid 1rpx $Dark-border-color;
  623. background-color: $Dark-row-background-color;
  624. }
  625. }
  626. .drag-content {
  627. .drag-icon {
  628. border-bottom: solid 1rpx $Dark-border-color;
  629. background-color: $Dark-row-background-color;
  630. }
  631. }
  632. }
  633. &.move {
  634. box-shadow: 0 1px 5px $Dark-shadow-color-moveing;
  635. }
  636. }
  637. }
  638. }
  639. // 定义颜色 end
  640. .HM-drag-sort {
  641. display: flex;
  642. flex-direction: column;
  643. position: relative;
  644. overflow: hidden;
  645. .scroll-view {
  646. box-sizing: border-box;
  647. }
  648. .rowBox,
  649. .rowBox-shadow {
  650. width: 100%;
  651. .hm-row-shadow,
  652. .hm-row {
  653. display: flex;
  654. flex-direction: row;
  655. width: 100%;
  656. .modules {
  657. width: 100%;
  658. display: flex;
  659. flex-direction: row;
  660. justify-content: space-between;
  661. box-sizing: border-box;
  662. .row-content {
  663. width: 100%;
  664. flex-shrink: 1;
  665. .row {
  666. display: flex;
  667. align-items: center;
  668. padding-left: 12px;
  669. box-sizing: border-box;
  670. .icon {
  671. width: 30px;
  672. height: 30px;
  673. border-radius: 6px;
  674. margin-right: 13px;
  675. }
  676. .text {
  677. font-size: 13px;
  678. }
  679. }
  680. }
  681. .drag-content {
  682. flex-shrink: 0;
  683. .drag-icon {
  684. width: 50px;
  685. display: flex;
  686. justify-content: center;
  687. align-items: center;
  688. box-sizing: border-box;
  689. .iconfont {
  690. font-size: 22px;
  691. color: #c7c7cb;
  692. }
  693. }
  694. }
  695. }
  696. }
  697. .hm-row-shadow {
  698. &.move {
  699. opacity: 0.8;
  700. view {
  701. border-bottom-width: 0;
  702. }
  703. }
  704. }
  705. .hm-row {
  706. opacity: 1;
  707. &.hide {
  708. opacity: 0;
  709. }
  710. &.ani {
  711. transition: transform 0.2s;
  712. -webkit-transition: transform 0.2s;
  713. }
  714. }
  715. &:last-child {
  716. .hm-row {
  717. view {
  718. border-bottom-width: 0;
  719. }
  720. }
  721. }
  722. }
  723. .rowBox-shadow {
  724. position: absolute;
  725. z-index: 100;
  726. display: none;
  727. &.show {
  728. display: flex !important;
  729. }
  730. &.hide {
  731. display: none !important;
  732. }
  733. }
  734. .list {
  735. display: flex;
  736. flex-direction: column;
  737. // transform-style:preserve-3d;
  738. }
  739. }
  740. </style>