How to use selectValue method in ng-mocks

Best JavaScript code snippet using ng-mocks

DATABIND_COMPONENTS.js

Source:DATABIND_COMPONENTS.js Github

copy

Full Screen

1/**2 * 数据绑定配置页面支持的组件列表及配置信息3 * components[n] 数据绑定配置页面各组件,其具体配置属性如下:4 * type {String} 组件类型5 * show {Boolean} 组件图标是否展示 默认true6 * switch {Boolean} 是否可以切换至其他组件 默认true7 * iconClass {String} 组件图标对应类名8 * cells {Array} 组件支持的字段框集合9 * cells[n] {Object} 单个字段框配置对象10 * cells[n].collectType: 0 不可汇总 1 必须汇总 2 可汇总11 * cells[n].min 格子最少字段数量12 * cells[n].max 格子最多字段数量13 * cells[n].valid(len,lenArr) 格子内字段情况验证 len{Number}: 当前格子包含的字段数量 lenArr{Aray}: 当前格子组的字段数集合14 * allowFieldTypes {Array} 格子可接收字段的类型集合,如果不设置该字段则表示该格子不限制拖入字段的类型15 */16/**17 *18 * @param {Number} len 当前格子包含的字段数量19 * @param {Array} lenArr 当前格子组的字段数集合20 */21function commonValid(len, lenArr) {22 let result = {23 accept: true,24 result: true,25 errmsg: ""26 };27 let { min, max } = this;28 if (min && len < min) {29 result.result = false;30 result.errmsg = this.tip ? this.tip : "至少需要" + min + "个字段";31 }32 if (max && len > max) {33 result.result = false;34 result.errmsg = "字段数量超出,最多允许" + max + "个字段";35 }36 if (max && len >= max) {37 result.accept = false;38 }39 return result;40}41export default [42 {43 type: "table",44 name: "表格",45 iconClass: "layout-table",46 cells: [47 {48 title: "表列",49 valueKey: "datas",50 collectType: {51 defaultValue: 0,52 selectValue: 253 },54 valid: commonValid55 }56 ]57 },58 {59 type: "chartBar",60 name: "柱状图",61 iconClass: "layout-bar",62 cells: [63 {64 title: "x轴",65 valueKey: "xAxis",66 min: 1,67 max: 4,68 dirll: true,69 collectType: {70 defaultValue: 0,71 selectValue: 072 },73 valid: commonValid74 },75 {76 title: "系列",77 valueKey: "series",78 max: 1,79 collectType: {80 defaultValue: 0,81 selectValue: 082 },83 valid: commonValid84 },85 {86 title: "y轴",87 valueKey: "yAxis",88 min: 1,89 max: 5,90 collectType: {91 defaultValue: 1,92 selectValue: 193 },94 valid: commonValid95 }96 ]97 },98 {99 type: "chartPie",100 name: "饼图",101 iconClass: "layout-pie",102 cells: [103 {104 title: "类别",105 valueKey: "types",106 min: 1,107 max: 4,108 dirll: true,109 collectType: {110 defaultValue: 0,111 selectValue: 0112 },113 valid: commonValid114 },115 {116 title: "指标",117 valueKey: "counter",118 min: 1,119 max: 1,120 collectType: {121 defaultValue: 1,122 selectValue: 1123 },124 valid: commonValid125 }126 ]127 },128 {129 type: "chartLine",130 name: "折线图",131 iconClass: "layout-line",132 cells: [133 {134 title: "x轴",135 valueKey: "xAxis",136 min: 1,137 max: 4,138 dirll: true,139 collectType: {140 defaultValue: 0,141 selectValue: 0142 },143 valid: commonValid144 },145 {146 title: "系列",147 valueKey: "series",148 max: 1,149 collectType: {150 defaultValue: 0,151 selectValue: 0152 },153 valid: commonValid154 },155 {156 title: "y轴",157 valueKey: "yAxis",158 min: 1,159 max: 5,160 collectType: {161 defaultValue: 1,162 selectValue: 1163 },164 valid: commonValid165 }166 ]167 },168 {169 type: "chartMix",170 name: "折柱混合图",171 iconClass: "layout-linebar",172 cells: [173 {174 title: "x轴",175 valueKey: "xAxis",176 min: 1,177 max: 4,178 dirll: true,179 collectType: {180 defaultValue: 0,181 selectValue: 0182 },183 valid: commonValid184 },185 {186 title: "系列",187 valueKey: "series",188 max: 1,189 collectType: {190 defaultValue: 0,191 selectValue: 0192 },193 valid: commonValid194 },195 {196 title: "柱状指标",197 valueKey: "barCount",198 max: 5,199 collectType: {200 defaultValue: 1,201 selectValue: 1202 },203 valid: function(len, arr) {204 let result = commonValid.call(this, len, arr);205 if (arr[2] === 0 && arr[3] === 0) {206 result.result = false;207 result.errmsg = "柱状指标和折线指标至少其中一个有字段";208 }209 return result;210 }211 },212 {213 title: "折线指标",214 valueKey: "lineCount",215 max: 5,216 collectType: {217 defaultValue: 1,218 selectValue: 1219 },220 valid: function(len, arr) {221 let result = commonValid.call(this, len, arr);222 if (arr[2] === 0 && arr[3] === 0) {223 result.result = false;224 result.errmsg = "柱状指标和折线指标至少其中一个有字段";225 }226 return result;227 }228 }229 ]230 },231 {232 type: "chartDot",233 name: "大数据散点图",234 iconClass: "layout-dot",235 cells: [236 {237 title: "名称",238 valueKey: "name",239 min: 1,240 max: 1,241 collectType: {242 defaultValue: 0,243 selectValue: 0244 },245 valid: commonValid246 },247 {248 title: "类别",249 valueKey: "types",250 max: 1,251 collectType: {252 defaultValue: 0,253 selectValue: 0254 },255 valid: commonValid256 },257 {258 title: "x轴",259 valueKey: "xAxis",260 allowFieldTypes: ["number"],261 min: 1,262 max: 1,263 tip: "需拖入1个数值字段",264 collectType: {265 defaultValue: 0,266 selectValue: 2267 },268 valid: commonValid269 },270 {271 title: "y轴",272 valueKey: "yAxis",273 allowFieldTypes: ["number"],274 min: 1,275 max: 1,276 tip: "需拖入1个数值字段",277 collectType: {278 defaultValue: 0,279 selectValue: 2280 },281 valid: commonValid282 },283 {284 title: "大小",285 valueKey: "size",286 allowFieldTypes: ["number"],287 max: 1,288 collectType: {289 defaultValue: 0,290 selectValue: 2291 },292 valid: commonValid293 }294 ]295 },296 {297 type: "chartNestpie",298 name: "嵌套环形图",299 iconClass: "layout-nestpie",300 cells: [301 {302 title: "类别1",303 valueKey: "series1",304 max: 1,305 collectType: {306 defaultValue: 0,307 selectValue: 0308 },309 valid: function(len, arr) {310 let result = commonValid.call(this, len, arr);311 if (arr[0] === 0 && arr[1] === 0 && arr[2] === 0) {312 result.result = false;313 result.errmsg = "类别1、类别2、类别3至少其中一个有字段";314 }315 return result;316 }317 },318 {319 title: "类别2",320 valueKey: "series2",321 max: 1,322 collectType: {323 defaultValue: 0,324 selectValue: 0325 },326 valid: function(len, arr) {327 let result = commonValid.call(this, len, arr);328 if (arr[0] === 0 && arr[1] === 0 && arr[2] === 0) {329 result.result = false;330 result.errmsg = "类别1、类别2、类别3至少其中一个有字段";331 }332 return result;333 }334 },335 {336 title: "类别3",337 valueKey: "series3",338 max: 1,339 collectType: {340 defaultValue: 0,341 selectValue: 0342 },343 valid: function(len, arr) {344 let result = commonValid.call(this, len, arr);345 if (arr[0] === 0 && arr[1] === 0 && arr[2] === 0) {346 result.result = false;347 result.errmsg = "类别1、类别2、类别3至少其中一个有字段";348 }349 return result;350 }351 },352 {353 title: "指标",354 valueKey: "counter",355 min: 1,356 max: 1,357 collectType: {358 defaultValue: 1,359 selectValue: 1360 },361 valid: commonValid362 }363 ]364 },365 {366 type: "chartRose",367 name: "南丁格尔玫瑰图",368 iconClass: "layout-rose",369 cells: [370 {371 title: "类别",372 valueKey: "types",373 min: 1,374 max: 4,375 dirll: true,376 collectType: {377 defaultValue: 0,378 selectValue: 0379 },380 valid: commonValid381 },382 {383 title: "指标",384 valueKey: "counter",385 min: 1,386 max: 1,387 collectType: {388 defaultValue: 1,389 selectValue: 1390 },391 valid: commonValid392 }393 ]394 },395 {396 type: "heatchart",397 iconClass: "layout-heatchart",398 name: "热力图",399 cells: [400 {401 title: "x轴",402 valueKey: "xAxis",403 min: 1,404 max: 1,405 collectType: {406 defaultValue: 0,407 selectValue: 0408 },409 valid: commonValid410 },411 {412 title: "y轴",413 valueKey: "yAxis",414 min: 1,415 max: 1,416 collectType: {417 defaultValue: 0,418 selectValue: 0419 },420 valid: commonValid421 },422 {423 title: "指标",424 valueKey: "counter",425 min: 1,426 max: 1,427 collectType: {428 defaultValue: 1,429 selectValue: 1430 },431 valid: commonValid432 }433 ]434 },435 {436 type: "chartFunnel",437 iconClass: "layout-chartFunnel",438 name: "漏斗图",439 cells: [440 {441 title: "类别",442 valueKey: "types",443 min: 1,444 max: 4,445 dirll: true,446 collectType: {447 defaultValue: 0,448 selectValue: 0449 },450 valid: commonValid451 },452 {453 title: "指标",454 valueKey: "counter",455 min: 1,456 max: 1,457 collectType: {458 defaultValue: 1,459 selectValue: 1460 },461 valid: commonValid462 }463 ]464 },465 {466 type: "chartGauge",467 iconClass: "layout-chartgauge",468 name: "油量图",469 cells: [470 {471 title: "指标",472 valueKey: "counter",473 min: 1,474 max: 1,475 collectType: {476 defaultValue: 1,477 selectValue: 1478 },479 valid: commonValid480 }481 ]482 },483 {484 type: "chartWordCloud",485 iconClass: "layout-wordCloud",486 name: "词云图",487 cells: [488 {489 title: "词名",490 valueKey: "types",491 min: 1,492 max: 1,493 collectType: {494 defaultValue: 0,495 selectValue: 0496 },497 valid: commonValid498 },499 {500 title: "指标",501 valueKey: "counter",502 max: 1,503 collectType: {504 defaultValue: 1,505 selectValue: 1506 },507 valid: commonValid508 }509 ]510 },511 {512 type: "graph",513 name: "关联关系图",514 iconClass: "layout-graph",515 cells: [516 {517 title: "源节点",518 valueKey: "node",519 min: 1,520 max: 1,521 collectType: {522 defaultValue: 0,523 selectValue: 0524 },525 valid: commonValid526 },527 {528 title: "源节点类别",529 valueKey: "nodeType",530 max: 1,531 collectType: {532 defaultValue: 0,533 selectValue: 0534 },535 valid: commonValid536 },537 {538 title: "源节点数据",539 valueKey: "nodeData",540 min: 1,541 max: 1,542 collectType: {543 defaultValue: 1,544 selectValue: 1545 },546 valid: commonValid547 },548 {549 title: "目标节点",550 valueKey: "tarNode",551 min: 1,552 max: 1,553 collectType: {554 defaultValue: 0,555 selectValue: 0556 },557 valid: commonValid558 },559 {560 title: "目标节点类别",561 valueKey: "tarNodeType",562 max: 1,563 collectType: {564 defaultValue: 0,565 selectValue: 0566 },567 valid: commonValid568 },569 {570 title: "目标节点数据",571 valueKey: "tarNodeData",572 min: 1,573 max: 1,574 collectType: {575 defaultValue: 1,576 selectValue: 1577 },578 valid: commonValid579 },580 {581 title: "关系",582 valueKey: "relation",583 max: 1,584 collectType: {585 defaultValue: 0,586 selectValue: 0587 },588 valid: commonValid589 }590 ]591 },592 {593 type: "sankey",594 name: "桑基图",595 iconClass: "layout-sankey",596 cells: [597 {598 title: "来源",599 valueKey: "node",600 min: 1,601 max: 1,602 collectType: {603 defaultValue: 0,604 selectValue: 0605 },606 valid: commonValid607 },608 {609 title: "目标",610 valueKey: "target",611 min: 1,612 max: 1,613 collectType: {614 defaultValue: 0,615 selectValue: 0616 },617 valid: commonValid618 },619 {620 title: "指标",621 valueKey: "counter",622 min: 1,623 max: 1,624 collectType: {625 defaultValue: 1,626 selectValue: 1627 },628 valid: commonValid629 }630 ]631 },632 {633 type: "themeriver",634 iconClass: "layout-themeriver",635 name: "河流图",636 cells: [637 {638 title: "x轴",639 valueKey: "xAxis",640 min: 1,641 max: 4,642 collectType: {643 defaultValue: 0,644 selectValue: 0645 },646 valid: commonValid647 },648 {649 title: "系列",650 valueKey: "series",651 max: 1,652 collectType: {653 defaultValue: 0,654 selectValue: 0655 },656 valid: commonValid657 },658 {659 title: "指标",660 valueKey: "counter",661 min: 1,662 max: 5,663 collectType: {664 defaultValue: 1,665 selectValue: 1666 },667 valid: commonValid668 }669 ]670 },671 {672 type: "heatMap",673 iconClass: "layout-heat",674 name: "热力图地图",675 cells: [676 {677 title: "经度",678 valueKey: "lng",679 allowFieldTypes: ["number"],680 min: 1,681 max: 1,682 collectType: {683 defaultValue: 0,684 selectValue: 0685 },686 tip: "可拖入1个数值字段",687 valid: commonValid688 },689 {690 title: "纬度",691 valueKey: "lat",692 allowFieldTypes: ["number"],693 min: 1,694 max: 1,695 collectType: {696 defaultValue: 0,697 selectValue: 0698 },699 tip: "可拖入1个数值字段",700 valid: commonValid701 },702 {703 title: "指标",704 valueKey: "counter",705 allowFieldTypes: ["number"],706 min: 1,707 max: 1,708 collectType: {709 defaultValue: 1,710 selectValue: 2711 },712 valid: commonValid713 }714 ]715 },716 {717 type: "markerMap",718 iconClass: "layout-marker",719 name: "标记地图",720 cells: [721 {722 title: "名称",723 valueKey: "name",724 max: 1,725 collectType: {726 defaultValue: 0,727 selectValue: 0728 },729 valid: commonValid730 },731 {732 title: "经度",733 valueKey: "lng",734 allowFieldTypes: ["number"],735 min: 1,736 max: 1,737 collectType: {738 defaultValue: 0,739 selectValue: 0740 },741 tip: "可拖入1个数值字段",742 valid: commonValid743 },744 {745 title: "纬度",746 valueKey: "lat",747 allowFieldTypes: ["number"],748 min: 1,749 max: 1,750 collectType: {751 defaultValue: 0,752 selectValue: 0753 },754 tip: "可拖入1个数值字段",755 valid: commonValid756 },757 {758 title: "显示信息",759 valueKey: "info",760 max: 5,761 collectType: {762 defaultValue: 0,763 selectValue: 2764 },765 valid: commonValid766 }767 ]768 },769 {770 type: "routeMap",771 iconClass: "layout-route",772 name: "路线地图",773 cells: [774 {775 title: "路线名称",776 valueKey: "routeName",777 min: 1,778 max: 1,779 collectType: {780 defaultValue: 0,781 selectValue: 0782 },783 valid: commonValid784 },785 {786 title: "路线信息",787 valueKey: "routeSeries",788 max: 1,789 collectType: {790 defaultValue: 0,791 selectValue: 0792 },793 valid: commonValid794 },795 {796 title: "经度",797 valueKey: "lng",798 allowFieldTypes: ["number"],799 min: 1,800 max: 1,801 collectType: {802 defaultValue: 0,803 selectValue: 0804 },805 tip: "可拖入1个数值字段",806 valid: commonValid807 },808 {809 title: "纬度",810 valueKey: "lat",811 allowFieldTypes: ["number"],812 min: 1,813 max: 1,814 collectType: {815 defaultValue: 0,816 selectValue: 0817 },818 tip: "可拖入1个数值字段",819 valid: commonValid820 },821 {822 title: "坐标信息",823 valueKey: "counter",824 max: 1,825 collectType: {826 defaultValue: 0,827 selectValue: 0828 },829 valid: commonValid830 }831 ]832 },833 {834 type: "migrateMap",835 iconClass: "layout-migrate",836 name: "迁徙地图",837 cells: [838 {839 title: "起点名称",840 valueKey: "startName",841 max: 1,842 collectType: {843 defaultValue: 0,844 selectValue: 0845 },846 valid: commonValid847 },848 {849 title: "起点经度",850 valueKey: "startLng",851 allowFieldTypes: ["number"],852 min: 1,853 max: 1,854 collectType: {855 defaultValue: 0,856 selectValue: 0857 },858 tip: "可拖入1个数值字段",859 valid: commonValid860 },861 {862 title: "起点纬度",863 valueKey: "startLat",864 allowFieldTypes: ["number"],865 min: 1,866 max: 1,867 collectType: {868 defaultValue: 0,869 selectValue: 0870 },871 tip: "可拖入1个数值字段",872 valid: commonValid873 },874 {875 title: "终点名称",876 valueKey: "targetName",877 max: 1,878 collectType: {879 defaultValue: 0,880 selectValue: 0881 },882 valid: commonValid883 },884 {885 title: "终点经度",886 valueKey: "targetLng",887 allowFieldTypes: ["number"],888 min: 1,889 max: 1,890 collectType: {891 defaultValue: 0,892 selectValue: 0893 },894 tip: "可拖入1个数值字段",895 valid: commonValid896 },897 {898 title: "终点纬度",899 valueKey: "targetLat",900 allowFieldTypes: ["number"],901 min: 1,902 max: 1,903 collectType: {904 defaultValue: 0,905 selectValue: 0906 },907 tip: "可拖入1个数值字段",908 valid: commonValid909 },910 {911 title: "显示信息",912 valueKey: "info",913 max: 5,914 collectType: {915 defaultValue: 0,916 selectValue: 2917 },918 valid: commonValid919 }920 ]921 },922 {923 type: "select",924 show: false,925 switch: false,926 name: "单选下拉框",927 cells: [928 {929 title: "数据",930 valueKey: "value",931 min: 1,932 max: 1,933 collectType: {934 defaultValue: 0,935 selectValue: 2936 },937 valid: commonValid938 }939 ]940 },941 {942 type: "multiselect",943 show: false,944 switch: false,945 name: "多选下拉框",946 cells: [947 {948 title: "数据",949 valueKey: "value",950 min: 1,951 max: 1,952 collectType: {953 defaultValue: 0,954 selectValue: 2955 },956 valid: commonValid957 }958 ]959 },960 {961 type: "checkbox",962 show: false,963 switch: false,964 name: "复选框",965 cells: [966 {967 title: "数据",968 valueKey: "value",969 min: 1,970 max: 1,971 collectType: {972 defaultValue: 0,973 selectValue: 2974 },975 valid: commonValid976 }977 ]978 },979 {980 type: "radio",981 show: false,982 switch: false,983 name: "单选框",984 cells: [985 {986 title: "数据",987 valueKey: "value",988 min: 1,989 max: 1,990 collectType: {991 defaultValue: 0,992 selectValue: 2993 },994 valid: commonValid995 }996 ]997 },998 {999 type: "timeline",1000 show: false,1001 switch: false,1002 name: "动态数轴",1003 cells: [1004 {1005 title: "数据",1006 valueKey: "value",1007 min: 1,1008 max: 1,1009 collectType: {1010 defaultValue: 0,1011 selectValue: 21012 },1013 valid: commonValid1014 }1015 ]1016 },1017 {1018 type: "indexCard",1019 show: false,1020 switch: false,1021 name: "指标卡",1022 cells: [1023 {1024 title: "类别",1025 valueKey: "type",1026 min: 0,1027 max: 1,1028 collectType: {1029 defaultValue: 0,1030 selectValue: 01031 },1032 valid: commonValid1033 },1034 {1035 title: "指标",1036 valueKey: "counter",1037 min: 1,1038 max: 2,1039 collectType: {1040 defaultValue: 1,1041 selectValue: 11042 },1043 valid: commonValid1044 }1045 ]1046 }...

Full Screen

Full Screen

order_addcart.js

Source:order_addcart.js Github

copy

Full Screen

1import { getCartList, getCartCounts, changeCartNum, cartDel} from '../../api/order.js';2import { getProductHot, collectAll } from '../../api/store.js';3import { setFormId } from '../../api/api.js';4const app = getApp();5const util = require('../../utils/util.js');6Page({7 /**8 * 页面的初始数据9 */10 data: {11 parameter: {12 'navbar': '1',13 'return': '0',14 'title': '购物车',15 'color': false16 },17 navH: 0,18 cartCount:0,19 goodsHidden:true,20 footerswitch: true,21 host_product: [],22 cartList:[],23 isAllSelect:false,//全选24 selectValue:[],//选中的数据25 selectCountPrice:0.00,26 isGoIndex: true,27 iShidden: false,28 },29 /**30 * 生命周期函数--监听页面加载31 */32 onLoad: function (options) {33 var that = this;34 that.setData({35 navH: app.globalData.navHeight36 });37 if (app.globalData.token) that.setData({ iShidden:true});38 },39 /**40 * 关闭授权41 * 42 */43 onCloseAuto: function () {44 this.setData({ iShidden: true });45 },46 subDel:function (event) {47 var formId = event.detail.formId, that = this, selectValue = that.data.selectValue;48 setFormId(formId);49 if (selectValue.length > 0) 50 cartDel(selectValue).then(res=>{51 that.getCartList();52 that.getCartNum();53 });54 else 55 return app.Tips({ title:'请选择产品'});56 },57 getSelectValueProductId:function(){58 var that = this;59 var validList = that.data.cartList.valid;60 var selectValue = that.data.selectValue;61 var productId = [];62 if (selectValue.length > 0){ for (var index in validList){if(that.inArray(validList[index].id, selectValue)) { productId.push(validList[index].product_id);}}};63 return productId;64 },65 subCollect: function (event){66 var formId = event.detail.formId, that = this, selectValue = that.data.selectValue;67 setFormId(formId);68 if (selectValue.length > 0) {69 var selectValueProductId = that.getSelectValueProductId();70 collectAll(that.getSelectValueProductId().join(',')).then(res=>{71 return app.Tips({title:res.msg,icon:'success'});72 }).catch(err=>{73 return app.Tips({ title: err });74 });75 } else {76 return app.Tips({ title:'请选择产品'});77 }78 },79 subOrder: function (event){80 var formId = event.detail.formId, that = this, selectValue = that.data.selectValue;81 setFormId(formId);82 if (selectValue.length > 0){83 wx.navigateTo({url:'/pages/order_confirm/index?cartId=' + selectValue.join(',')});84 }else{85 return app.Tips({ title:'请选择产品'});86 }87 },88 checkboxAllChange: function (event){89 var value = event.detail.value;90 if (value.length > 0) { this.setAllSelectValue(1)}91 else { this.setAllSelectValue(0) }92 },93 setAllSelectValue:function(status){94 var that = this;95 var selectValue = [];96 var valid = that.data.cartList.valid;97 if (valid.length > 0) {98 for (var index in valid) {99 if (status == 1){100 valid[index].checked = true;101 selectValue.push(valid[index].id);102 }else valid[index].checked = false;103 }104 var validData = "cartList.valid";105 that.setData({106 [validData]: valid,107 selectValue: selectValue,108 });109 that.switchSelect();110 }111 },112 checkboxChange: function (event){113 var that = this;114 var value = event.detail.value;115 var valid = this.data.cartList.valid;116 for (var index in valid){117 if (that.inArray(valid[index].id, value)) valid[index].checked = true;118 else valid[index].checked = false;119 }120 var validData = "cartList.valid";121 this.setData({ 122 [validData]: valid,123 isAllSelect: value.length == this.data.cartList.valid.length,124 selectValue: value,125 })126 this.switchSelect();127 },128 inArray:function(search, array){129 for (var i in array) { if (array[i] == search) { return true; } }130 return false;131 },132 switchSelect:function(){133 var that = this;134 var validList = that.data.cartList.valid;135 var selectValue = that.data.selectValue;136 var selectCountPrice = 0.00;137 if (selectValue.length < 1) { that.setData({ selectCountPrice: selectCountPrice }); }138 else{139 for (var index in validList){140 if (that.inArray(validList[index].id, selectValue)){141 selectCountPrice = Number(selectCountPrice) + Number(validList[index].cart_num) * Number(validList[index].truePrice)142 }143 }144 that.setData({ selectCountPrice: selectCountPrice.toFixed(2) });145 }146 },147 subCart:function(event){148 var that = this;149 var status = false;150 var index = event.currentTarget.dataset.index;151 var item = that.data.cartList.valid[index];152 console.log(item);153 item.cart_num = item.cart_num - 1;154 if (item.cart_num < 1) status = true;155 if (item.cart_num <= 1) { 156 item.cart_num = 1;157 item.numSub = true; 158 } else { item.numSub = false;item.numAdd = false; }159 if (false == status) {160 that.setCartNum(item.id, item.cart_num, function (data) {161 var itemData = "cartList.valid[" + index + "]";162 that.setData({ [itemData]: item });163 that.switchSelect();164 });165 }166 },167 addCart: function (event) {168 var that = this;169 var index = event.currentTarget.dataset.index;170 var item = that.data.cartList.valid[index];171 item.cart_num = item.cart_num + 1;172 var productInfo = item.productInfo;173 if (productInfo.hasOwnProperty('attrInfo') && item.cart_num >= item.productInfo.attrInfo.stock) {174 item.cart_num = item.productInfo.attrInfo.stock;175 item.numAdd = true;176 item.numSub = false; 177 } else if (item.cart_num >= item.productInfo.stock) {178 item.cart_num = item.productInfo.stock;179 item.numAdd = true;180 item.numSub = false; 181 } else { item.numAdd = false; item.numSub = false; }182 that.setCartNum(item.id, item.cart_num, function (data) {183 var itemData = "cartList.valid[" + index + "]";184 that.setData({ [itemData]: item });185 that.switchSelect();186 });187 },188 setCartNum(cartId, cartNum, successCallback) {189 var that = this;190 changeCartNum(cartId, cartNum).then(res=>{191 successCallback && successCallback(res.data);192 });193 },194 getCartNum: function () {195 var that = this;196 getCartCounts().then(res=>{197 that.setData({ cartCount: res.data.count });198 });199 },200 getCartList: function () {201 var that = this;202 getCartList().then(res=>{203 var cartList = res.data;204 var valid = cartList.valid;205 var numSub = [{ numSub: true }, { numSub: false }];206 var numAdd = [{ numAdd: true }, { numAdd: false }];207 if (valid.length > 0) {208 for (var index in valid) {209 if (valid[index].cart_num == 1) { valid[index].numSub = true; }210 else { valid[index].numSub = false; }211 var productInfo = valid[index].productInfo;212 if (productInfo.hasOwnProperty('attrInfo') && valid[index].cart_num == valid[index].productInfo.attrInfo.stock) {213 valid[index].numAdd = true;;214 } else if (valid[index].cart_num == valid[index].productInfo.stock) {215 valid[index].numAdd = true;;216 } else { valid[index].numAdd = false; }217 valid[index].checked = false;218 }219 }220 that.setData({ cartList: cartList, goodsHidden: cartList.valid.length <= 0 ? false : true });221 that.switchSelect();222 });223 },224 getHostProduct: function () {225 var that = this;226 getProductHot().then(res=>{227 that.setData({ host_product: res.data });228 });229 },230 goodsOpen:function(){231 var that = this;232 that.setData({233 goodsHidden: !that.data.goodsHidden234 })235 },236 manage:function(){237 var that = this;238 that.setData({239 footerswitch: !that.data.footerswitch240 })241 },242 /**243 * 生命周期函数--监听页面初次渲染完成244 */245 onReady: function () {246 },247 onLoadFun: function () {248 this.getHostProduct();249 this.getCartList();250 this.getCartNum();251 },252 /**253 * 生命周期函数--监听页面显示254 */255 onShow: function () {256 if (app.globalData.isLog == true) {257 this.getHostProduct();258 this.getCartList();259 this.getCartNum();260 this.setData({261 goodsHidden: true,262 footerswitch: true,263 host_product: [],264 cartList: [],265 isAllSelect: false,//全选266 selectValue: [],//选中的数据267 selectCountPrice: 0.00,268 cartCount: 0,269 iShidden:true270 });271 }272 },273 unsetCart:function(){274 let that=this,ids=[];275 for (var i = 0, len = that.data.cartList.invalid.length;i < len;i++){276 ids.push(that.data.cartList.invalid[i].id);277 }278 cartDel(ids).then(res=>{279 app.Tips({ title: '清除成功' });280 that.setData({ 'cartList.invalid': [] });281 }).catch(res=>{282 });283 },284 /**285 * 生命周期函数--监听页面隐藏286 */287 onHide: function () {288 },289 /**290 * 生命周期函数--监听页面卸载291 */292 onUnload: function () {293 },294 /**295 * 页面相关事件处理函数--监听用户下拉动作296 */297 onPullDownRefresh: function () {298 },...

Full Screen

Full Screen

public.js

Source:public.js Github

copy

Full Screen

1export const allSelectStatus = [2 "upstreamChannelStatus", "configStatus", "dictStatus", "operatorStatus", 3 "roleStatus", "appStatus", "regionStatus", "userStatus", "configStatus", 4 "dictStatus", "configStatus", "taskStatus", "typeStatus"5]6export const allSelectMessageStatus = ["smsSendStatus"]7export const allSelectTaskStatus = ["taskStatus"]8export const supportCustomSign = ["supportCustomSign", ]9export const supportQueryBalance = ["supportQueryBalance", ]10export const allUserType = ["userType" ]11export const allOperatorSex = ["operatorSex" ]12export const allOperatorLevel = ["operatorLevel" ]13export const allResetType = ["resetType" ]14export const allDictLevel = ["dictLevel" ]15export const allRegionGroupCode = ["regionGroupCode" ]16export const hiddenAllId = ["id"]17export const regionGroupCode = [18 {selectText: '默认', selectValue: 'defalut' },19 {selectText: '其他', selectValue: '' }20];21export const resetType = [22 {selectText: '全局', selectValue: 'default' },23 {selectText: '月重置', selectValue: 'month' },24 {selectText: '日重置', selectValue: 'day' },25 {selectText: '时重置', selectValue: 'hour' }26];27export const dictLevel = [28 {selectText: '全局', selectValue: 'whole' },29 {selectText: '应用', selectValue: 'app' }30];31export const operatorLevel = [32 {selectText: '归属管理员', selectValue: 'belonging_admin' },33 {selectText: '普通操作员', selectValue: 'ordinary_operator' }34];35export const operatorSex = [36 {selectText: '男', selectValue: 'male' },37 {selectText: '女', selectValue: 'female' }38];39export const userType = [40 {selectText: '全部', selectValue: '' },41 {selectText: '支撑平台操作人员', selectValue: 'operation_supplier' }42];43export const queryStatus = [44 {selectText: '全部', selectValue: '' },45 {selectText: '启用', selectValue: 'enabled' },46 {selectText: '禁用', selectValue: 'disabled' }47];48export const smsSendStatus = [49 {selectText: '全部', selectValue: '' },50 {selectText: '成功', selectValue: 'success' },51 {selectText: '失败', selectValue: 'fail' }52];53export const taskStatus = [54 {selectText: '全部', selectValue: '' },55 {selectText: '正常', selectValue: 'default' },56 {selectText: '暂停', selectValue: 'paused' }57];58export const querySupport = [59 {selectText: '全部', selectValue: '' },60 {selectText: '支持', selectValue: 'support' },61 {selectText: '不支持', selectValue: 'not_support' }62];63export const queryAddOrEditStatus = [64 {selectText: '启用', selectValue: 'enabled' },65 {selectText: '禁用', selectValue: 'disabled' }66];67export const queryAddOrEditSupport = [68 {selectText: '支持', selectValue: 'support' },69 {selectText: '不支持', selectValue: 'not_support' }70];71export const menuShowType = [72 { selectText: '显示', selectValue: 'display' },73 { selectText: '隐藏', selectValue: 'hide' }74];75export const menuStatus = [76 { selectText: '启用', selectValue: 'enabled' },77 { selectText: '禁用', selectValue: 'disabled' }78];79export const menuType = [80 { selectText: '菜单', selectValue: 'menu' },81 { selectText: '目录', selectValue: 'catalog' },82 { selectText: '按钮', selectValue: 'button' }83];84export const in_array = (arr, element) => {85 for (let i = 0; i < arr.length; i++) {86 if (arr[i] == element) {87 return true;88 }89 }90 return false;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { selectValue } from 'ng-mocks';2import { ComponentFixture, TestBed } from '@angular/core/testing';3import { AppComponent } from './app.component';4import { FormsModule } from '@angular/forms';5describe('AppComponent', () => {6 let component: AppComponent;7 let fixture: ComponentFixture<AppComponent>;8 beforeEach(async () => {9 await TestBed.configureTestingModule({10 imports: [FormsModule],11 }).compileComponents();12 });13 beforeEach(() => {14 fixture = TestBed.createComponent(AppComponent);15 component = fixture.componentInstance;16 fixture.detectChanges();17 });18 it('should create', () => {19 expect(component).toBeTruthy();20 });21 it('should select value', () => {22 selectValue(fixture, 'select', '2');23 expect(component.selectedValue).toEqual('2');24 });25});26import { Component } from '@angular/core';27@Component({28})29export class AppComponent {30 selectedValue = '';31 title = 'ng-mocks';32 { value: 1, title: 'First' },33 { value: 2, title: 'Second' },34 { value: 3, title: 'Third' },35 ];36}37 <h1>{{ title }}</h1>38 <select class="form-control" [(ngModel)]="selectedValue">39 <option *ngFor="let option of options" [value]="option.value">{{ option.title }}</option>40.container {41 width: 50%;42 margin: 0 auto;43 padding: 20px;44 border: 1px solid #ccc;45 border-radius: 5px;46}47import { ComponentFixture, TestBed } from '@angular/core/testing';48import { AppComponent } from './app.component';49describe('AppComponent', () => {50 let component: AppComponent;51 let fixture: ComponentFixture<AppComponent>;52 beforeEach(async () => {53 await TestBed.configureTestingModule({54 }).compileComponents();55 });56 beforeEach(() => {57 fixture = TestBed.createComponent(AppComponent);58 component = fixture.componentInstance;59 fixture.detectChanges();60 });61 it('should create', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { selectValue } from 'ng-mocks';2describe('TestComponent', () => {3 let component: TestComponent;4 let fixture: ComponentFixture<TestComponent>;5 beforeEach(() => {6 TestBed.configureTestingModule({7 });8 fixture = TestBed.createComponent(TestComponent);9 component = fixture.componentInstance;10 });11 it('should select value', () => {12 selectValue(fixture, 'select', 'value');13 expect(component.value).toEqual('value');14 });15});16@Component({17 <select (change)="onSelect($event)">18})19export class TestComponent {20 value = '';21 onSelect(event: Event) {22 this.value = (event.target as HTMLSelectElement).value;23 }24}25<select (change)="onSelect($event)">26import { ComponentFixture, TestBed } from '@angular/core/testing';27import { TestComponent } from './test.component';28describe('TestComponent', () => {29 let component: TestComponent;30 let fixture: ComponentFixture<TestComponent>;31 beforeEach(() => {32 TestBed.configureTestingModule({33 });34 fixture = TestBed.createComponent(TestComponent);35 component = fixture.componentInstance;36 });37 it('should select value', () => {38 const select = fixture.debugElement.query(By.css('select'));39 select.triggerEventHandler('change', { target: { value: 'value' } });40 expect(component.value).toEqual('value');41 });42});43import { Component } from '@angular/core';44@Component({45 <select (change)="onSelect($event)">46})47export class TestComponent {48 value = '';49 onSelect(event: Event) {50 this.value = (event.target as HTMLSelectElement).value;51 }52}53<select (change)="onSelect($event)">

Full Screen

Using AI Code Generation

copy

Full Screen

1import { selectValue } from 'ng-mocks';2import { MyComponent } from './my.component';3import { ComponentFixture, TestBed } from '@angular/core/testing';4import { ReactiveFormsModule } from '@angular/forms';5describe('MyComponent', () => {6 let component: MyComponent;7 let fixture: ComponentFixture<MyComponent>;8 beforeEach(async () => {9 await TestBed.configureTestingModule({10 imports: [ReactiveFormsModule],11 }).compileComponents();12 });13 beforeEach(() => {14 fixture = TestBed.createComponent(MyComponent);15 component = fixture.componentInstance;16 fixture.detectChanges();17 });18 it('should create', () => {19 expect(component).toBeTruthy();20 });21 it('should select value', () => {22 selectValue(fixture, 'select', '2');23 expect(component.form.get('select')?.value).toEqual('2');24 });25});26import { Component } from '@angular/core';27import { FormControl, FormGroup } from '@angular/forms';28@Component({29})30export class MyComponent {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { selectValue } from 'ng-mocks';2import { Component } from '@angular/core';3import { ComponentFixture, TestBed } from '@angular/core/testing';4@Component({5 (ngModelChange)="onChange($event)"6})7class TestComponent {8 value: string;9 onChange(value: string) {10 this.value = value;11 }12}13describe('TestComponent', () => {14 let component: TestComponent;15 let fixture: ComponentFixture<TestComponent>;16 beforeEach(async () => {17 await TestBed.configureTestingModule({18 }).compileComponents();19 });20 beforeEach(() => {21 fixture = TestBed.createComponent(TestComponent);22 component = fixture.componentInstance;23 fixture.detectChanges();24 });25 it('should change value', () => {26 selectValue(fixture, '2');27 expect(component.value).toBe('2');28 });29});30import { selectValue } from 'ng-mocks';31import { Component } from '@angular/core';32import { ComponentFixture, TestBed } from '@angular/core/testing';33@Component({34})35class TestComponent {}36describe('TestComponent', () => {37 let component: TestComponent;38 let fixture: ComponentFixture<TestComponent>;39 beforeEach(async () => {40 await TestBed.configureTestingModule({41 }).compileComponents();42 });43 beforeEach(() => {44 fixture = TestBed.createComponent(TestComponent);45 component = fixture.componentInstance;46 fixture.detectChanges();47 });48 it('should change value', () => {49 selectValue(fixture, '2');50 expect(component.value).toBe('2');51 });52});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { selectValue } from 'ng-mocks';2import { TestBed } from '@angular/core/testing';3import { AppComponent } from './app.component';4import { ComponentFixture } from '@angular/core/testing';5import { By } from '@angular/platform-browser';6import { tick } from '@angular/core/testing';7import { fakeAsync } from '@angular/core/testing';8describe('AppComponent', () => {9 let component: AppComponent;10 let fixture: ComponentFixture<AppComponent>;11 beforeEach(async () => {12 await TestBed.configureTestingModule({13 })14 .compileComponents();15 });16 beforeEach(() => {17 fixture = TestBed.createComponent(AppComponent);18 component = fixture.componentInstance;19 fixture.detectChanges();20 });21 it('should create the app', () => {22 expect(component).toBeTruthy();23 });24 it('should render title', () => {25 const fixture = TestBed.createComponent(AppComponent);26 fixture.detectChanges();27 const compiled = fixture.nativeElement;28 expect(compiled.querySelector('.content span').textContent).toContain('ng-mocks app is running!');29 });30 it('should select the first value of the select', () => {31 selectValue(fixture, 'select', '1');32 tick();33 fixture.detectChanges();34 const select = fixture.debugElement.query(By.css('select')).nativeElement;35 expect(select.value).toBe('1');36 });37 it('should select the second value of the select', () => {38 selectValue(fixture, 'select', '2');39 tick();40 fixture.detectChanges();41 const select = fixture.debugElement.query(By.css('select')).nativeElement;42 expect(select.value).toBe('2');43 });44 it('should select the third value of the select', () => {45 selectValue(fixture, 'select', '3');

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2 it('should be able to get the value of a select', () => {3 const fixture = MockRender(`4 `);5 const select = fixture.debugElement.query(By.css('select'));6 const value = selectValue(select);7 expect(value).toBe('1');8 });9});10describe('test', () => {11 it('should be able to get the value of a select', () => {12 const fixture = MockRender(`13 `);14 const select = fixture.debugElement.query(By.css('select'));15 const value = selectValue(select);16 expect(value).toBe('1');17 });18});19describe('test', () => {20 it('should be able to get the value of a select', () => {21 const fixture = MockRender(`22 `);23 const select = fixture.debugElement.query(By.css('select'));24 const value = selectValue(select);25 expect(value).toBe('1');26 });27});28describe('test', () => {29 it('should be able to get the value of a select', () => {30 const fixture = MockRender(`31 `);32 const select = fixture.debugElement.query(By.css('select'));33 const value = selectValue(select);34 expect(value).toBe('1');35 });36});37describe('test', () => {38 it('should be able to get the value of a select', () => {39 const fixture = MockRender(`

Full Screen

Using AI Code Generation

copy

Full Screen

1var selectValue = ngMocks.selectValue;2var component = ngMocks.find('app');3var form = ngMocks.find('form').componentInstance;4var control = form.form.get('name');5expect(control.value).toEqual('Nancy');6selectValue(component, 'name', 'Bess');7expect(control.value).toEqual('Bess');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ng-mocks automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful