simple-demo.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /*****
  2. *
  3. * Assuming a HTML like
  4. *
  5. * <... id="test-app-1">
  6. * <... v-for="oneuser in userlist">
  7. * {{oneuser.id}} , name: {{oneuser.name}}
  8. * </...>
  9. *
  10. * </...>
  11. *
  12. */
  13. var test_vue_app = new Vue({
  14. el : "test-app-1",
  15. data : {
  16. userlist : [{id:1, name:"hello"}]
  17. }
  18. });
  19. /******************************************************************************
  20. //
  21. // To load directly from JS(jQuery)
  22. //
  23. /*****************************************************************************/
  24. function js_load_something(){
  25. var uid = 5; //for test.
  26. BasicFunction.get_data("smartUsers/list"+"?userId="+uid,
  27. /**
  28. * 下面的function是访问网络成功后的结果回调,obj 类似
  29. *
  30. * http://south.niimei.com:8866/server/smartUsers/list
  31. * {
  32. * "ret":"10000","detail":null,"field":null,"model":
  33. * {"page":1,"pageSize":15,"totalPage":1,"totalResult":15,
  34. * "list":
  35. * [
  36. * {
  37. * "uid":3,"usn":"cell_13520583918","pss":"64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107",
  38. * "name":"HelloWorld","title":"","priv":"view,order,deliver,pay","state":0,"sess":"iOgxGPkFIV3JxBlBfCv",
  39. * "phone":"13520583918","schoolDistrict":null,"userExpPts":null,"userGroup":null,"userVcoin":null,"registerTime":null,
  40. * "lastLoginTime":null,"wxUnionid":null,"wxEngineid":null,"wxOpenid":null,"note":null
  41. * },
  42. * {..第二条数据..},
  43. * {..第三条数据..}
  44. * ]
  45. * }
  46. * }
  47. * @param obj
  48. */
  49. function (obj) {
  50. var parsedObj = first_parse(this, obj);
  51. if(parsedObj != null && parsedObj != undefined) {
  52. test_vue_app = parsedObj.list;
  53. } else {
  54. // error
  55. }
  56. } //end of f (obj, status)
  57. ); // end of get_data
  58. }
  59. /******************************************************************************
  60. //
  61. // To load using DataObject + DataService + Module stuff
  62. //
  63. *****************************************************************************/
  64. //Module means some component (need only to draw);
  65. var test_vue_module = new Module("nothing", "smartUsers");
  66. test_vue_module.drawData = function (data) {
  67. test_vue_app.data.userlist.pop();
  68. for(let i = 0; i < data.len(); i++) {
  69. test_vue_app.data.userlist.push(data.getSorted(i));
  70. }
  71. } ;
  72. var loader = new (function(){
  73. /* this is the main data service that is auto-updating your data*/
  74. this.userListServ = new DataObjectService("smartUsers", AUTO, "?ext=1");
  75. // Optional for setting up self-defined interval
  76. // this.userListServ.autoInterval = 300;
  77. // this.userListServ.setUpInterval();
  78. /**
  79. * load Once, as is.
  80. */
  81. this.loadOnce = function(){
  82. var list = this.userListServ.list;
  83. test_vue_module.setData(list);
  84. };
  85. /***
  86. * loadOften : to auto-load some data
  87. */
  88. this.loadOften = function(){
  89. // Binding Intervals to DataService
  90. this.userListServ.bind(function (data) {
  91. // auto call
  92. test_vue_module.setData(data);
  93. });
  94. };
  95. })();
  96. //To load once
  97. loader.loadOnce();
  98. //To auto-refresh
  99. // loader.loadOften();
  100. // 上传货品信息
  101. /*
  102. BasicFunction.get_data("smartIdentity/updateBatch", function (response) {
  103. console.log("------ Data Rcvd in PresentReg --------");
  104. console.log(response);
  105. if(response.ret === "10000"){
  106. this.$router.push('index');
  107. } else {
  108. // 注册失败的处理
  109. Toast.fail("上传失败,请检查网络");
  110. }
  111. }, [{"reviewId":1,"userId":1,"dormDistrict":10,
  112. "userSex":1,"userSchoolCard":20123333222,
  113. "userReviewStatus":1000,
  114. "reviewerId":1,"reviewerNote":"nmo",
  115. "reviewerNoteToUser":"noo"}]);
  116. 基本格式
  117. szuhuanhuan2018
  118. 登录 转义密码 就是 encodeURIComponent("实际密码")
  119. BasicFunction.get_data("ajaxlogin?u=手机号&p=(转义密码)", 回调函数, {})
  120. 验证码登录
  121. BasicFunction.get_data("ajaxotplogin?otp=", callback, {})
  122. 注册
  123. BasicFunction.get_data("ajaxregister?u=手机号&p=转义密码", 回调函数, {})
  124. 发送验证码
  125. BasicFunction.get_data("ajaxsendotp?u=手机号", 回调函数, {})
  126. 新建 (数据列表就是 [{...实际数据...}])
  127. BasicFunction.get_data("数据接口名称/saveBatch", 回调函数, 数据列表)
  128. 修改
  129. BasicFunction.get_data("数据接口名称/updateBatch", 回调函数, 数据列表)
  130. 搜索(获取)
  131. BasicFunction.get_data("数据接口名称/list?条件1=数据1&条件2=数据2&.....", 回调函数, {})
  132. 用户数据:
  133. smartUsers/list
  134. [{
  135. "uid":3, // 用户id
  136. "usn":"13520583918", // 登录用户名
  137. "pss":"64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107",
  138. "name":"HelloWorld", // 昵称
  139. "title":"",
  140. "priv":"view,order,deliver,pay",
  141. "state":0, // 状态
  142. "sess":"iOgxGPkFIV3JxBlBfCv",
  143. "phone":"13520583918", // 电话号码
  144. "schoolDistrict":null, // 宿舍区 0: 斋区, 1: 西南, 2: 南区, 3: 西丽
  145. "userExpPts":null,
  146. "userGroup":null,
  147. "userVcoin":null,
  148. "registerTime":null, // 注册时间
  149. "lastLoginTime":null,
  150. "wxUnionid":null,
  151. "wxEngineid":null,
  152. "wxOpenid":null,
  153. "note":null
  154. },
  155. 新建货品:
  156. smartGoods/saveBatch
  157. [{
  158. "goodid":"", // 货品id
  159. "name":"萌犬毛绒抱枕", // 货品名
  160. "goodsNo":"A2",
  161. "modelId":"1",
  162. "ownerId":"18", // 货品所有者id
  163. "goodFirstKind":"1000", // 目标性别 男: 0,女: 1
  164. "goodSecondKind":"2000", // 标签 0~13
  165. "sellPrice":"0.0",
  166. "marketPrice":"0.0",
  167. "costPrice":"0.0",
  168. "upTime":"2018-12-10 01:01:01",
  169. "downTime":"2018-12-10 01:01:01",
  170. "createTime":"2018-12-10 01:01:01", // 货品注册时间
  171. "storeNums":"1",
  172. "img":"attachment/simple/acsac089e1nnsaxx72190dm.jpg", // 图片名
  173. "isDel":"0", // 是否被删除,0: 未被删 1: 被删,首页不显示
  174. "content":"none",
  175. "keywords":"none",
  176. "description":"绒毛玩具或填充玩具,中国大陆较常用“毛绒玩具”、香港为“毛公仔”,是...", // 货品描述
  177. "searchWords":"毛绒,玩具",
  178. "weight":"0.4",
  179. "point":"4",
  180. "unit":"10",
  181. "brandId":"1",
  182. "visit":"1",
  183. "favorite":"1",
  184. "sort":"1", // 货品状态 0: 审核中, 1: 匹配中, 2: 匹配成功, 3: 交换成功, 4: 审核失败
  185. "listImg":"attachment/simple/acsac089e1nnsaxx72190dm.jpg",
  186. "smallImg":"attachment/simple/bicno912nounx7xsg28d1nidx.jpg",
  187. "specArray":"{}","exp":"0"
  188. }]
  189. 新建货品审核单
  190. smartGoodReview/saveBatch
  191. [{"reviewId":"","goodId":"3","applicantId":"19","reviewerId":"0","reviewResult":"0","applyTime":"2018-12-10 01:01:01","reviewTime":"2018-12-10 01:01:01","previousReview":"0","reviewNote":"暂未审核","displayNote":"暂未审核"}]
  192. 新建货品池内条目(入池)
  193. smartGoodPool/saveBatch
  194. [{"poolItemId":"","goodId":"3","goodSenderId":"5","goodQuantity":"1","goodQuality":"100","goodFirstKind":"1000","reviewStatus":"1000","goodTargetRole":"1","goodTargetKind":"2","inpoolStatus":"1000"}]
  195. 新建评论
  196. smartOrderFeedback/saveBatch
  197. [{
  198. "feedbackId":"",
  199. "orderId":"13", // 收到的礼物的id
  200. "goodId":"3",
  201. "ratingStatus":"1000",
  202. "ratingMajor":"5", // 评分
  203. "ratingMinor":"4500",
  204. "content":"还不错,5颗星", // 评论内容
  205. "ratingTime":"2018-12-10 01:01:01"
  206. }]
  207. 新建用户身份审核单(校园卡审核)
  208. smartIdentity/saveBatch
  209. [{
  210. "reviewId":"",
  211. "userId":18, // 用户id
  212. "dormDistrict":1, // 宿舍区 0: 斋区, 1: 西南, 2: 南区, 3: 西丽
  213. "userSex":1, // 用户性别
  214. "userSchoolCard":20123333222,
  215. "userReviewStatus":1000,
  216. "reviewerId":1,
  217. "reviewerNote":"nmo",
  218. "reviewerNoteToUser":"noo"
  219. }]
  220. 新建订单(配对成功)
  221. *** 前端不用操作 ***
  222. smartOrder/saveBatch
  223. [{"id":"","userId":"18","paymentId":"0","deliveryId":"0","merchandise":"{}","status":"1","payStatus":"0","distributionStatus":"0","dueAmount":"0.0","paidAmount":"0.0","taxes":"0","payableFreight":"0","realFreight":"0","payFee":"0","promotions":"0","discount":"1","orderAmount":"0","payTime":"2018-12-10 01:01:01","sendTime":"","createTime":"","completionTime":"","acceptTime":"","invoice":"0","invoiceTitle":"","postscript":"","note":"内部匹配","prop":"{}","exp":"0","point":"0","type":"0"}]
  224. 统计用(用户点击信息,页面位置+页面按钮/区域代码=clickEvent)
  225. [{"clickId":"","clickEvent":"100001","clickTime":"1544443423082","clickIdentity":"18"}]
  226. ****************
  227. ***** 查找:*****
  228. ****************
  229. 查找已经准备接收的礼物
  230. smartOrder/list
  231. [{"id":28,"userId":3,"paymentId":0,"deliveryId":0,"merchandise":"[{\"q\":1,\"model\":1,\"id\":\"3\",\"spec\":[{\"v\":\"100\",\"i\":1002}]},{\"q\":1,\"model\":1,\"id\":\"6\",\"spec\":[{\"v\":\"350\",\"i\":1002}]}]","status":2,"payStatus":2,"distributionStatus":0,"dueAmount":25.11,"paidAmount":0.0,"taxes":0.0,"payableFreight":0.0,"realFreight":0.0,"payFee":0.0,"promotions":0.49,"discount":1.0,"orderAmount":25.6,"payTime":"2017-12-23 10:38:20","sendTime":"2017-12-23 10:38:20","createTime":"2017-12-23 10:38:20","completionTime":"2017-12-23 10:38:20","acceptTime":"0","invoice":0,"invoiceTitle":"empty","postscript":"","note":"","prop":"{\"wechat\":1}","exp":0,"point":0,"type":1}]
  232. *************
  233. * // 第一阶段: 上传文件到fileServerURL
  234. function fileServerDeal(lst, fileServerURL, lstId) {
  235. uploadParams.uploadURI = fileServerURL;
  236. var formData = new FormData();
  237. upload_status_report("正在上传 - 第"+(lstId+1)+"个文件", (lstId + 1) +" / "+ lst.length);
  238. formData.append('file', $('#fileInput_'+lst[lstId])[0].files[0]);
  239. $.ajax({
  240. url: fileServerURL,
  241. type: 'POST',
  242. cache: false,
  243. data: formData,
  244. processData: false,
  245. contentType: false,
  246. now_list_id: lstId,
  247. now_lst:lst
  248. }).always(fileServerRet);
  249. }
  250. BasicFunction.getSigned(['checkJsApi', '...', '...'], function(){
  251. wx.ready(.......);
  252. });
  253. */