detail.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. import common from '../../utils/util';
  2. import server from '../../utils/main';
  3. const app = getApp();
  4. var times = 1;
  5. var pageIndex = 0;
  6. var QuestionItem = [];
  7. var tempAnswerList = [];
  8. var arrAnswerID = [];
  9. var isAndroid = false;
  10. const waitTime = ["", "10秒钟", "15秒钟", "20秒钟", "25秒钟"];
  11. Page({
  12. data: {
  13. version: app.globalData.version,
  14. IsShowMenu: false,
  15. filter: 'horizontal',
  16. //filter: 'vertical',
  17. PageNumber: 1,
  18. PageCount: 60,
  19. IsFinished: false,
  20. arrPage: [],
  21. ShowLoading: false,
  22. IsDistabled: "",
  23. NameClass: "",
  24. AddDisabled: "",
  25. SubDisabled: "btnAddSubDisabled",
  26. HelpHidden7: true,
  27. HelpHidden3: true,
  28. HelpHidden8: true,
  29. ShowAndroidNotice: false,
  30. },
  31. onLoad: function (options) {
  32. var that = this;
  33. var id = options.id;
  34. isAndroid = false;
  35. if (app.globalData.systemInfo.system && app.globalData.systemInfo.system.indexOf("Android") >= 0)
  36. isAndroid = true;
  37. this.setData({
  38. Containnerheight: server.getWindowHeight(),
  39. ID: id,
  40. ShowAndroidNotice: isAndroid,
  41. });
  42. var systemInfo = wx.getSystemInfoSync();
  43. if (systemInfo.system && systemInfo.system.indexOf("Android") >= 0) {
  44. times = 2;
  45. }
  46. this.getDetail(id);
  47. if (id > 0) {
  48. common.getStorageValue(this, "HelpHidden3", false, function () {
  49. that.showHelp();
  50. });
  51. } else {
  52. common.getStorageValue(this, "HelpHidden8", false, function () {
  53. that.showHelp8();
  54. });
  55. }
  56. common.getStorageValue(this, "IsShare", 0, function () {
  57. if (that.data.IsShare == 0 &&
  58. app.globalData.userInfo.IsMember == 0 &&
  59. app.globalData.userInfo.IsShow == 1 &&
  60. app.globalData.IsLocked == 1
  61. ) {
  62. wx.navigateTo({
  63. url: '../../package4/main/share',
  64. })
  65. }
  66. });
  67. },
  68. onShow: function () {
  69. if (this.data.ID == -1)
  70. this.getDetail(this.data.ID);
  71. },
  72. onUnload: function () {
  73. wx.hideLoading();
  74. this.closeHelp();
  75. },
  76. getDetail: function (id) {
  77. var item = {};
  78. if (id > 0) {
  79. var data = wx.getStorageSync('QuestionTypeList');
  80. for (var i = 0; i < data.length; i++) {
  81. for (var k = 0; k < data[i].List.length; k++) {
  82. if (id == data[i].List[k].ID) {
  83. item = data[i].List[k];
  84. item.Example[0] = item.Example[0].replace("+", " + ").replace("-", " - ").replace("×", " × ").replace("÷", " ÷ ");
  85. if (item.Example[1])
  86. item.Example[1] = item.Example[1].replace("+", " + ").replace("-", " - ").replace("×", " × ").replace("÷", " ÷ ");
  87. item.IconName = app.globalData.fileUrl + item.IconName;
  88. if (item.Name.length > 12)
  89. item.NameClass = "text2";
  90. break;
  91. }
  92. }
  93. }
  94. } else {
  95. item.Name = "我的错题集";
  96. var list = wx.getStorageSync('ErrorList');
  97. item.ErrorList = list;
  98. }
  99. this.setData({
  100. QuestionTypeItem: item,
  101. });
  102. //有竖式则缺省竖式
  103. if (item.QuestionNumber3 > 0) {
  104. this.menuClick({
  105. currentTarget: {
  106. dataset: {
  107. id: "vertical"
  108. }
  109. }
  110. })
  111. }
  112. },
  113. gotoError: function (e) {
  114. wx.navigateTo({
  115. url: '../main/errorlist',
  116. });
  117. },
  118. gotoAnswer: function (e) {
  119. wx.navigateTo({
  120. url: '../main/answer',
  121. });
  122. this.closeHelp2();
  123. },
  124. getFinish: function () {
  125. server.playSound("/sounds/click.mp3");
  126. this.setData({
  127. ShowLoading: true,
  128. BtnText: "全部保存到相册",
  129. });
  130. wx.hideLoading();
  131. arrAnswerID = [];
  132. tempAnswerList = [];
  133. this.getAnswerID();
  134. if (this.data.ID > 0) {
  135. this.getList(this.data.ID);
  136. } else {
  137. this.getErrorList();
  138. }
  139. this.closeHelp();
  140. },
  141. //重新生成试卷
  142. ResetFinish: function () {
  143. var that = this;
  144. wx.showLoading({
  145. title: "正在重置",
  146. complete: function () {
  147. var list = that.data.arrPage;
  148. for (var i = 0; i < list.length; i++) {
  149. wx.removeSavedFile({
  150. filePath: list[i].TempImagePath
  151. });
  152. }
  153. that.setData({
  154. arrPage: [],
  155. PageNumber: 1,
  156. });
  157. var tempList = wx.getStorageSync("AnswerList");
  158. for (var i = 0; i < list.length; i++) {
  159. tempList.shift();
  160. }
  161. wx.setStorageSync("AnswerList", tempList);
  162. wx.hideLoading();
  163. that.getFinish();
  164. }
  165. });
  166. },
  167. //题卡数据列表
  168. getList: function (id) {
  169. var that = this;
  170. var pageNum = that.data.PageNumber;
  171. var QuestionTypeCategory = 3;
  172. if (that.data.filter == "horizontal")
  173. QuestionTypeCategory = 2;
  174. pageIndex = 0;
  175. server.getData('GetQuestionTypesPrint?ID=' + id + '&QuestionTypeCategory=' + QuestionTypeCategory + '&PageNum=' + pageNum, function (data) {
  176. //console.log("UserInfo:" + data);
  177. if (data) {
  178. that.setData({
  179. IsFinished: true,
  180. arrPage: [],
  181. IsDistabled: "",
  182. WaitTime: waitTime[that.data.PageNumber],
  183. });
  184. QuestionItem = data;
  185. QuestionItem.IconName = that.data.QuestionTypeItem.IconName;
  186. // if (isAndroid) {
  187. // console.log("android");
  188. // const query = wx.createSelectorQuery();
  189. // query.select('#Canvas')
  190. // .fields({ node: true, size: true })
  191. // .exec((res) => {
  192. // const canvas = res[0].node;
  193. // const ctx = canvas.getContext('2d');
  194. // canvas.width = 1050;
  195. // canvas.height = 1485;
  196. // wx.canvasToTempFilePath({
  197. // x: 0,
  198. // y: 0,
  199. // width: canvas.width,
  200. // height: canvas.height,
  201. // canvas: canvas,
  202. // success: function(res2) {
  203. // that.saveImage();
  204. // }
  205. // });
  206. // });
  207. // }
  208. // else {
  209. that.saveImage();
  210. // }
  211. }
  212. });
  213. },
  214. //错题列表
  215. getErrorList: function () {
  216. var that = this;
  217. QuestionItem = that.data.QuestionTypeItem;
  218. if (QuestionItem.ErrorList.length > 0) {
  219. QuestionItem.Category = -1; //错题集类别
  220. QuestionItem.QuestionTypeCategory = 2;
  221. QuestionItem.CategoryName = "";
  222. QuestionItem.Name = "我的错题集";
  223. QuestionItem.QuestionTypeLevel = "";
  224. QuestionItem.PageCount = QuestionItem.ErrorList.length > 60 ? 60 : QuestionItem.ErrorList.length;
  225. QuestionItem.QuestionList = QuestionItem.ErrorList;
  226. QuestionItem.CreateTime = common.formatDateCHSLong(new Date());
  227. QuestionItem.IconName = app.globalData.fileUrl + "questioncard_icon_grade0102_size01.png";
  228. QuestionItem.QuestionList = common.randomArray(QuestionItem.QuestionList);
  229. delete QuestionItem.ErrorList;
  230. pageIndex = 0;
  231. that.setData({
  232. IsFinished: true,
  233. arrPage: [],
  234. IsDistabled: "",
  235. WaitTime: waitTime[that.data.PageNumber],
  236. });
  237. // if (isAndroid) {
  238. // console.log("android");
  239. // const query = wx.createSelectorQuery();
  240. // query.select('#Canvas')
  241. // .fields({ node: true, size: true })
  242. // .exec((res) => {
  243. // const canvas = res[0].node;
  244. // const ctx = canvas.getContext('2d');
  245. // canvas.width = 1050;
  246. // canvas.height = 1485;
  247. // wx.canvasToTempFilePath({
  248. // x: 0,
  249. // y: 0,
  250. // width: canvas.width,
  251. // height: canvas.height,
  252. // canvas: canvas,
  253. // success: function(res2) {
  254. // that.saveImage();
  255. // }
  256. // });
  257. // });
  258. // }
  259. // else {
  260. that.saveImage();
  261. // }
  262. } else {
  263. this.setData({
  264. ShowLoading: false,
  265. });
  266. wx.showModal({
  267. title: "没有错题",
  268. showCancel: false,
  269. content: "先到“对答案”中给做错的题目打记号(点击题目序号)",
  270. });
  271. }
  272. },
  273. getAnswerID: function () {
  274. var list = wx.getStorageSync("AnswerList");
  275. var id = 1;
  276. if (list && list.length > 0) {
  277. list.sort(function (a, b) {
  278. return b.AnswerID - a.AnswerID;
  279. });
  280. id = list[0].AnswerID + 1;
  281. }
  282. for (var i = 0; i < this.data.PageNumber; i++)
  283. arrAnswerID.push(id + i);
  284. },
  285. saveImage: function () {
  286. var that = this;
  287. var item = QuestionItem;
  288. item.AnswerID = arrAnswerID.shift();
  289. const query = wx.createSelectorQuery();
  290. query.select('#Canvas')
  291. .fields({
  292. node: true,
  293. size: true
  294. })
  295. .exec((res) => {
  296. var canvas = res[0].node;
  297. var ctx = canvas.getContext('2d');
  298. canvas.width = 1050;
  299. canvas.height = 1485;
  300. ctx.textAlign="left";
  301. ctx.textBaseline="top";
  302. ctx.font = "12px";
  303. ctx.fillStyle="#ffffff";
  304. ctx.fillRect(0, 0, canvas.width, canvas.height);
  305. ctx.fillStyle = "#000000";
  306. var xStart = 60;
  307. var yStart = 247;
  308. var height = 150;
  309. if (item.QuestionTypeCategory == 2)
  310. height = 59;
  311. if (item.Category > 0) {
  312. if (item.PageCount == 18)
  313. height = 210;
  314. else if (item.PageCount == 15)
  315. height = 250;
  316. }
  317. //括号
  318. var index = 0;
  319. for (var i = 0; i < 3; i++) {
  320. for (var j = 0; j < item.PageCount / 3; j++) {
  321. index++;
  322. if (index <= item.QuestionList.length) {
  323. ctx.fillText("(", xStart + i * 310, yStart + j * height);
  324. ctx.fillText(")", xStart + i * 310 + 22, yStart + j * height);
  325. }
  326. }
  327. }
  328. //编号
  329. index = 0;
  330. ctx.textAlign="center";
  331. var numberLeft = 12;
  332. if (isAndroid)
  333. numberLeft = 14;
  334. for (var i = 0; i < 3; i++) {
  335. for (var j = 0; j < item.PageCount / 3; j++) {
  336. index++;
  337. if (index <= item.QuestionList.length) {
  338. ctx.fillText(index, xStart + i * 310 + numberLeft, yStart + j * height);
  339. }
  340. }
  341. }
  342. //算式
  343. index = that.data.arrPage.length * item.PageCount;
  344. //ctx.setFontSize(24);
  345. ctx.font = "24px";
  346. var urlDiv=[];
  347. for (var i = 0; i < 3; i++) {
  348. for (var j = 0; j < item.PageCount / 3; j++) {
  349. index++;
  350. if (index <= item.QuestionList.length) {
  351. //横式
  352. if (item.QuestionTypeCategory == 2) {
  353. var A = item.QuestionList[index - 1].A.toString();
  354. if (item.QuestionList[index - 1].HiddenColumn == "A")
  355. A = "____";
  356. var OperateAB = item.QuestionList[index - 1].OperateAB.toString();
  357. //console.log(OperateAB);
  358. var B = item.QuestionList[index - 1].B.toString();
  359. if (item.QuestionList[index - 1].HiddenColumn == "B")
  360. B = "____";
  361. var equation = A + " " + OperateAB + " " + B;
  362. if (item.QuestionList[index - 1].C) {
  363. var OperateBC = item.QuestionList[index - 1].OperateBC.toString();
  364. var C = item.QuestionList[index - 1].C.toString();
  365. equation += " " + OperateBC + " " + C;
  366. if (item.QuestionList[index - 1].D) {
  367. var OperateCD = item.QuestionList[index - 1].OperateCD.toString();
  368. var D = item.QuestionList[index - 1].D.toString();
  369. equation += " " + OperateCD + " " + D;
  370. }
  371. }
  372. equation += " = ";
  373. var R = item.QuestionList[index - 1].R.toString();
  374. if (item.QuestionList[index - 1].HiddenColumn == "R")
  375. R = "";
  376. equation += R;
  377. var num = xStart + i * 310 + 31;
  378. for (var n = 0; n < equation.length; n++) {
  379. var len = getLength(equation[n]);
  380. num += len;
  381. if (equation[n] == ".") {
  382. ctx.fillText(equation[n], num + 3, yStart + j * 59 - 5);
  383. } else {
  384. var h = -8;
  385. if (equation[n] == "_")
  386. h = 0;
  387. ctx.fillText(equation[n], num, yStart + j * 59 + h);
  388. }
  389. }
  390. }
  391. //竖式
  392. else if (item.QuestionTypeCategory == 3) {
  393. var num1 = item.QuestionList[index - 1];
  394. var isAnswer = false;
  395. var width = 250;
  396. if (num1.OperateAB == "÷")
  397. width = 240;
  398. for (var n = 0; n < num1.Vertical.length; n++) {
  399. var num = xStart + i * 310 + width;
  400. var num2 = 0;
  401. for (var m = num1.Vertical[n].Array.length - 1; m >= 0; m--) {
  402. var str = "";
  403. if (num1.Vertical[n].Type == "line") {
  404. if (num1.OperateAB != "÷") {
  405. //var lineLength = num1.Vertical[n].Array.length * 30 + 20;
  406. var lineLength = 6 * 30 + 20;
  407. var lineTop = 4;
  408. //console.log(yStart + j * height + n * 30 + lineTop);
  409. ctx.moveTo(num, yStart + j * height + n * 30 + lineTop);
  410. ctx.lineTo(num - lineLength, yStart + j * height + n * 30 + lineTop);
  411. ctx.stroke();
  412. isAnswer = true;
  413. break;
  414. }
  415. } else {
  416. str = num1.Vertical[n].Array[m];
  417. if (num1.OperateAB == "÷" && str == "√") {
  418. isAnswer = true;
  419. var lineLength = num1.A.toString().length;
  420. var lineWidth = Math.floor(57 * (1 + num1.A.toString().length) / 2);
  421. var obj={};
  422. obj.url="../images/formula_division_size0" + lineLength + ".png";
  423. obj.num1=num - (num1.Vertical[n].Array.length - m) * 30 - 8;
  424. obj.num2=yStart + j * height + n * 30 - 10;
  425. obj.num3=lineWidth;
  426. obj.num4=39;
  427. urlDiv.push(obj);
  428. // var img = canvas.createImage();
  429. // img.src = "../images/formula_division_size0" + lineLength + ".png";
  430. // console.log(img.src);
  431. // img.onload = e => {
  432. // ctx.drawImage(img, num - (num1.Vertical[n].Array.length - m) * 30 - 8, yStart + j * height + n * 30 - 10, lineWidth, 39);
  433. // };
  434. }
  435. else if (num1.OperateAB == "÷" && n == 0) {} else if (num1.OperateAB == "÷" && n == 1) {
  436. ctx.fillText(str, num - (num1.Vertical[n].Array.length - m) * 10, yStart + j * height + n * 30);
  437. }
  438. else {
  439. if (str == ".") {
  440. ctx.fillText(str, num - (num1.Vertical[n].Array.length - m) * 30 + 15, yStart + j * height + n * 30);
  441. num2 = 30;
  442. } else if (str == "+" || str == "-" || str == "−" || str == "×" || str == "÷") {
  443. var lineLength = 6 * 30;
  444. ctx.fillText(str, num - lineLength, yStart + j * height + n * 30);
  445. num2 = 30;
  446. } else
  447. ctx.fillText(str, num - (num1.Vertical[n].Array.length - m) * 30 + num2, yStart + j * height + n * 30);
  448. }
  449. }
  450. }
  451. if (isAnswer)
  452. break;
  453. }
  454. }
  455. }
  456. }
  457. }
  458. ctx.textAlign="left";
  459. //ctx.setFontSize(32);
  460. ctx.font = "32px";
  461. ctx.fillText(item.Name, 60, 45);
  462. //ctx.setFontSize(12);
  463. ctx.font = "12px";
  464. ctx.fillText(item.CategoryName, 60, 90);
  465. ctx.fillText("共" + item.PageCount + "道题", 60, 125);
  466. ctx.fillText("第 "+(pageIndex+1).toString()+" / "+that.data.PageNumber+" 页", 60, 147);
  467. ctx.fillText("答案检索号", 768, 60);
  468. ctx.textAlign="right";
  469. ctx.fillText("出题时间 " + item.CreateTime, 875, 94);
  470. ctx.fillText("微信扫一扫 计时看答案", 875, 111);
  471. ctx.fillText("《数学计算题》选题 打印 扫码 批改", 875, 137);
  472. ctx.font = "32px";
  473. ctx.fillText(item.AnswerID, 872, 50);
  474. var img=canvas.createImage();
  475. img.src="../images/answer.png";
  476. img.onload = e => {
  477. ctx.drawImage(img, 890, 54, 100, 100);
  478. if (urlDiv.length>0){
  479. var img2=canvas.createImage();
  480. img2.src=urlDiv[0].url;
  481. img2.onload = e => {
  482. for(var k=0;k<urlDiv.length;k++)
  483. ctx.drawImage(img2, urlDiv[k].num1, urlDiv[k].num2, urlDiv[k].num3, urlDiv[k].num4);
  484. build();
  485. };
  486. }
  487. else
  488. build();
  489. };
  490. function build(){
  491. var w = 1050,h = 1485;
  492. wx.canvasToTempFilePath({
  493. x: 0,
  494. y: 0,
  495. width: w * times,
  496. height: h * times,
  497. destWidth: w * times,
  498. destHeight: h * times,
  499. canvas: canvas,
  500. success: function (res2) {
  501. //console.log(res2.tempFilePath);
  502. that.data.arrPage.push(res2.tempFilePath);
  503. item.TempImagePath = res2.tempFilePath;
  504. tempAnswerList.push(JSON.parse(JSON.stringify(item)));
  505. that.setData({
  506. arrPage: that.data.arrPage,
  507. });
  508. if (that.data.arrPage.length < that.data.PageNumber) {
  509. pageIndex++;
  510. that.saveImage();
  511. } else {
  512. //生成图片完成
  513. setTimeout(function () {
  514. that.setData({
  515. ShowLoading: false,
  516. });
  517. wx.pageScrollTo({
  518. scrollTop: 0,
  519. duration: 300
  520. });
  521. //存列表
  522. var tempList = wx.getStorageSync("AnswerList");
  523. if (!tempList)
  524. tempList = [];
  525. for (var x = 0; x < tempList.length; x++) {
  526. tempList[x].IsNew = 0;
  527. }
  528. for (var x = 0; x < tempAnswerList.length; x++) {
  529. var tempItem = tempAnswerList[x];
  530. var id = x * tempItem.PageCount;
  531. var arr = [];
  532. for (var y = 0; y < tempItem.QuestionList.length; y++) {
  533. if (y >= id && y < id + tempItem.PageCount) {
  534. arr.push(tempItem.QuestionList[y]);
  535. }
  536. }
  537. tempItem.QuestionList = arr;
  538. tempItem.IsNew = 1;
  539. tempList.unshift(tempItem);
  540. }
  541. wx.setStorageSync("AnswerList", tempList);
  542. common.getStorageValue(that, "HelpHidden7", false, function () {
  543. that.showHelp2();
  544. });
  545. }, 3000);
  546. }
  547. }
  548. });
  549. };
  550. });
  551. function getLength(str) {
  552. switch (str) {
  553. case "0":
  554. case "1":
  555. case "2":
  556. case "3":
  557. case "4":
  558. case "5":
  559. case "6":
  560. case "7":
  561. case "8":
  562. case "9":
  563. return 15;
  564. case ".":
  565. return 8;
  566. default:
  567. return 12;
  568. }
  569. }
  570. },
  571. //保存图片文件
  572. saveImageFile: function () {
  573. if (this.data.IsDistabled == "") {
  574. wx.showLoading({
  575. title: "保存中..."
  576. });
  577. var that = this;
  578. var count = 0;
  579. for (var i = 0; i < that.data.arrPage.length; i++) {
  580. wx.saveImageToPhotosAlbum({
  581. filePath: that.data.arrPage[i],
  582. success(res3) {
  583. console.log("save:" + res3.savedFilePath);
  584. count++
  585. if (count == that.data.arrPage.length) {
  586. wx.hideLoading();
  587. wx.showModal({
  588. title: "保存完成",
  589. showCancel: false,
  590. content: "请打开手机相册查看图片!",
  591. });
  592. that.setData({
  593. IsDistabled: "Distabled",
  594. BtnText: "已保存",
  595. });
  596. wx.pageScrollTo({
  597. scrollTop: 400,
  598. duration: 300
  599. });
  600. }
  601. },
  602. fail(err3) {
  603. console.log(err3);
  604. wx.openSetting();
  605. },
  606. complete() {
  607. wx.hideLoading();
  608. }
  609. })
  610. }
  611. }
  612. },
  613. changePageNumber: function (e) {
  614. var id = Number(e.currentTarget.dataset.id);
  615. this.data.PageNumber += id;
  616. var addDisabled = "",
  617. subDisabled = "";
  618. if (this.data.PageNumber <= 1) {
  619. this.data.PageNumber = 1;
  620. subDisabled = "btnAddSubDisabled";
  621. } else if (this.data.PageNumber >= 4) {
  622. this.data.PageNumber = 4;
  623. addDisabled = "btnAddSubDisabled";
  624. }
  625. this.setData({
  626. PageNumber: this.data.PageNumber,
  627. AddDisabled: addDisabled,
  628. SubDisabled: subDisabled,
  629. });
  630. },
  631. showImage: function (e) {
  632. var that = this;
  633. var id = e.currentTarget.dataset.id;
  634. wx.previewImage({
  635. current: that.data.arrPage[id], // 当前显示图片的http链接
  636. urls: that.data.arrPage // 需要预览的图片http链接列表
  637. });
  638. },
  639. closeLoading: function () {
  640. var that = this;
  641. that.setData({
  642. ShowLoading: false,
  643. IsFinished: false,
  644. });
  645. },
  646. menuClick: function (e) {
  647. this.data.filter = e.currentTarget.dataset.id;
  648. if (this.data.filter == "horizontal") {
  649. this.data.PageCount = this.data.QuestionTypeItem.QuestionNumber2;
  650. } else if (this.data.filter == "vertical") {
  651. this.data.PageCount = this.data.QuestionTypeItem.QuestionNumber3;
  652. }
  653. this.setData({
  654. filter: this.data.filter,
  655. IsShowMenu: false,
  656. PageCount: this.data.PageCount,
  657. });
  658. },
  659. closeMenu: function () {
  660. this.setData({
  661. IsShowMenu: false,
  662. });
  663. },
  664. openMenu: function () {
  665. this.setData({
  666. IsShowMenu: true,
  667. });
  668. },
  669. showHelp: function () {
  670. if (!this.data.HelpHidden3) {
  671. this.audioCtx = wx.createAudioContext('myAudio');
  672. var str = "嘿嘿,找到我了吗?我在车间的窗户里制作例题呢。如果这是你要的题型,去点“出题”按钮就对了。还要告诉你,一张卷子就是一张图片,题目数量请看提示。";
  673. server.playAudio(this.audioCtx, str);
  674. }
  675. },
  676. closeHelp: function () {
  677. this.setData({
  678. HelpHidden3: true,
  679. });
  680. wx.setStorageSync("HelpHidden3", true);
  681. this.audioCtx = wx.createAudioContext('myAudio');
  682. this.audioCtx.pause();
  683. },
  684. showHelp2: function () {
  685. if (!this.data.HelpHidden7) {
  686. this.audioCtx = wx.createAudioContext('myAudio');
  687. var str = "卷子出炉咯,棒棒哒!快去手机相册打印吧。我会等在首页上的答案资料室为你继续带路的。";
  688. server.playAudio(this.audioCtx, str);
  689. }
  690. },
  691. closeHelp2: function () {
  692. this.setData({
  693. HelpHidden7: true,
  694. });
  695. wx.setStorageSync("HelpHidden7", true);
  696. this.audioCtx = wx.createAudioContext('myAudio');
  697. this.audioCtx.pause();
  698. },
  699. showHelp8: function () {
  700. if (!this.data.HelpHidden8) {
  701. this.audioCtx = wx.createAudioContext('myAudio');
  702. var str = "发现错误是提高成绩的第一步。点一下题目数量右侧的图标,当有错题后,能查看和整理错题清单。";
  703. server.playAudio(this.audioCtx, str);
  704. }
  705. },
  706. closeHelp8: function () {
  707. this.setData({
  708. HelpHidden8: true,
  709. });
  710. wx.setStorageSync("HelpHidden8", true);
  711. this.audioCtx = wx.createAudioContext('myAudio');
  712. this.audioCtx.pause();
  713. },
  714. onShareAppMessage: function () {
  715. return {
  716. title: app.globalData.ShareTitle,
  717. path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
  718. imageUrl: app.globalData.ShareImage,
  719. }
  720. },
  721. })