shifang.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view>
  3. <view class="mvxyck" style="padding-top: 50rpx;">
  4. <view v-for="(item, index) in goodlist" :key="index">
  5. <view class="rectangular_54nz">
  6. <view class="rectangular_46ue">
  7. <view class="ynusc">{{index+1}}</view>
  8. <view class="the_warehouse">号仓</view>
  9. </view>
  10. <view class="box_fff">
  11. <view class="bnrmd">
  12. <view class="rectangular_67lk">{{item.name}}</view>
  13. <image :src="item.litpic" mode="widthFix" class="the_mask_73jy"></image>
  14. <view class="since">{{item.price}}</view>
  15. </view>
  16. <view class="stwdcp">
  17. <view class="le_ticket">乐票:
  18. <view class="sfwitk">{{ item.lpnum }}&nbsp;/&nbsp;{{item.cgkc}}%</view>
  19. </view>
  20. <view class="cycle_day">周期:
  21. <view class="sfwitk">{{ item.tianshu }}天&nbsp;/&nbsp;{{ item.shouyi }}%</view>
  22. </view>
  23. <view class="ws60cef">{{ item.kssj}}&nbsp;~&nbsp;{{ item.jssj}}</view>
  24. <view class="cycle_day" style="color: #829c52;">库存余量:
  25. <view class="sfwitk" style="color: #829c52;font-weight: bold;">{{ item.kucun }}</view>
  26. </view>
  27. <view class="fjpar">
  28. <!-- <view class="rectangular_61de_ismxl" @click="shifang(item.id, 1, index)" v-if="item.kucun>0 && item.zt==0">释放一单</view> -->
  29. <view class="rectangular_61de" v-if="item.kucun==0">库存已满</view>
  30. <view class="rectangular_61de" v-if="item.zt==1">释放中</view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. constants: {},
  44. goodlist: [],
  45. num: 0,
  46. id: 0,
  47. userinfo: null
  48. };
  49. },
  50. onShow() {
  51. var user = this.$api.getUserinfo();
  52. if (user) {
  53. this.userinfo = user;
  54. } else {
  55. this.userinfo = null;
  56. }
  57. this.getMhGoodlist();
  58. },
  59. filters: {
  60. formatDate: function(value, args) {
  61. var dt = new Date(value);
  62. if (args == 'yyyy-M-d') {
  63. // yyyy-M-d
  64. let year = dt.getFullYear();
  65. let month = dt.getMonth() + 1;
  66. let date = dt.getDate();
  67. return `${year}-${month}-${date}`;
  68. } else if (args == 'yyyy-M-d H:m:s') {
  69. // yyyy-M-d H:m:s
  70. let year = dt.getFullYear();
  71. let month = dt.getMonth() + 1;
  72. let date = dt.getDate();
  73. let hour = dt.getHours();
  74. let minute = dt.getMinutes();
  75. let second = dt.getSeconds();
  76. return `${year}-${month}-${date} ${hour}:${minute}:${second}`;
  77. } else if (args == 'yyyy-MM-dd') {
  78. // yyyy-MM-dd
  79. let year = dt.getFullYear();
  80. let month = (dt.getMonth() + 1).toString().padStart(2, '0');
  81. let date = dt
  82. .getDate()
  83. .toString()
  84. .padStart(2, '0');
  85. return `${year}-${month}-${date}`;
  86. } else if (args == 'HH:mm') {
  87. // yyyy-MM-dd
  88. let hour = dt
  89. .getHours()
  90. .toString()
  91. .padStart(2, '0');
  92. let minute = dt
  93. .getMinutes()
  94. .toString()
  95. .padStart(2, '0');
  96. return `${hour}:${minute}`;
  97. } else {
  98. // yyyy-MM-dd HH:mm:ss
  99. let year = dt.getFullYear();
  100. let month = (dt.getMonth() + 1).toString().padStart(2, '0');
  101. let date = dt
  102. .getDate()
  103. .toString()
  104. .padStart(2, '0');
  105. let hour = dt
  106. .getHours()
  107. .toString()
  108. .padStart(2, '0');
  109. let minute = dt
  110. .getMinutes()
  111. .toString()
  112. .padStart(2, '0');
  113. let second = dt
  114. .getSeconds()
  115. .toString()
  116. .padStart(2, '0');
  117. return `${year}-${month}-${date} ${hour}:${minute}:${second}`;
  118. }
  119. }
  120. },
  121. onLoad(option) {
  122. // console.log(option);
  123. },
  124. methods: {
  125. shifang(id, num, index) {
  126. if (!this.userinfo) {
  127. uni.showToast({
  128. title: '请先登录',
  129. icon: 'none'
  130. });
  131. return;
  132. }
  133. var that = this;
  134. that.goodlist[index].zt = 1
  135. var data = new Object();
  136. data.cid = id;
  137. data.uid = this.userinfo.id;
  138. data.num = num;
  139. //console.log(data)
  140. this.$api
  141. .MhGetModel(data, 'ppb/shifang')
  142. .then(res => {
  143. //console.log(res.data)
  144. if (res.data.code == 0) {
  145. uni.showToast({
  146. title: res.data.msg,
  147. icon: 'none'
  148. });
  149. that.getMhGoodlist()
  150. that.goodlist[index].zt = 0
  151. return;
  152. } else {
  153. uni.redirectTo({
  154. url: 'zrcg?lx=1'
  155. });
  156. }
  157. })
  158. .catch(err => {
  159. // console.log('request fail', JSON.stringify(err));
  160. });
  161. },
  162. getMhGoodlist() {
  163. var data = new Object();
  164. data.uid = this.userinfo.id;
  165. this.$api
  166. .MhGetModel(data, 'ppb/list')
  167. .then(res => {
  168. if (res.data.code != 1) {
  169. uni.showModal({
  170. title: '提示',
  171. content: res.data.msg,
  172. showCancel: false,
  173. success: function(res) {
  174. if (res.confirm) {
  175. uni.navigateBack({
  176. delta: 1
  177. });
  178. } else if (res.cancel) {
  179. console.log('用户点击取消');
  180. }
  181. }
  182. });
  183. return;
  184. } else {
  185. uni.hideLoading();
  186. this.goodlist = res.data.data;
  187. }
  188. })
  189. .catch(err => {
  190. // console.log('request fail', JSON.stringify(err));
  191. });
  192. }
  193. }
  194. };
  195. </script>
  196. <style lang="scss" scoped>
  197. @import "../lanhu_jingxi/index.scss";
  198. </style>
  199. <style>
  200. page {
  201. background: #f1f2f6;
  202. }
  203. </style>